How to write Japanese and Chinese in Linux on any window manager using fcitx

If your Linux system has a custom environment with window manager like i3wm, bspwm, dwm there is no problem. The method below doesn’t require toolbars, widgets, applets and other things.

Install fcitx

First we need to install fcitx:

sudo apt install fcitx

Then, we need to decide which language we want to use (Chinese or Japanese).

Packages for Japanese

If we want to use Japanese, it is needed to install fcitx-mozc package. It’s Japanese Input Method based on Japanese syllabary (Hiragana, Katakana). So with that we can type Kanji, like 人、魔。

Install fcitx-mozc package:

sudo apt install fcitx-mozc

And some Japanese fonts (may be any that you want):

sudo apt install fonts-takao-mincho

Packages for Chinese

If we want to use Chinese, it is needed to install fcitx-googlepinyin package. It’s Chinese Input Method based on Chinese syllabary (pinyin). So with that we can type Chinese character’s, like 吗,时。

Install fcitx-googlepinyin package:

sudo apt install fcitx-googlepinyin

And some Chinese fonts (may be any that you want):

sudo apt install xfonts-intl-chinese

Install both Japanese and Chinese packages

Of course, we can install both Chinese and Japanese input methods with fonts:

sudo apt install fcitx-mozc
sudo apt install fonts-takao-mincho
sudo apt install fcitx-googlepinyin
sudo apt install xfonts-intl-chinese

Setting up

It is needed to paste these lines in our ~/.xinitrc file:

export XMODIFIERS=​@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XIM=fcitx
fcitx

Thereby GTK and Qt libraries will understand which input methods to use. Last line “fcitx” is needed so that every time we turn computer on, fcitx will start automatically.

Now, let’s configure it. Run im-config:

im-config -c

When asked we want to update, press Yes.

Then, pick fcitx.

Now, let’s start our fcitx. If we don’t do that, our configtool will not work.

fcitx

When fcitx started, type fcitx-configtool:

fcitx-configtool

Do something like this:

fcitx-configtool with mozc and google pinyin
fcitx-configtool. How it looks like. Here are all the basic settings such as hotkeys, font size, input methods… Here you can customize any language you want.

Perhaps now it is better to reboot your system for all settings to take effect. Don’t forget to save this page in your bookmarks.

Everything should work now. Now we can go into a text editor.

Click on the input field, so to see the cursor blinking.

Then press Ctrl + Space. It’s default shortcut (may differ in new fcitx versions, so check fcitx-configtool settings and set your own shortcuts).

We should see that:

Hotkey for Google Pinyin in fcitx. Picture how it happens
Just press Ctrl + Space (default). If it doesn’t work, look in fcitx-configtool. There you can find a hotkey for this. Here’s what it looks like.

Then try to start typing letters.

Google Pinyin with fcitx in Linux + dwm
How it looks like. First you enter the pronunciation in pinyin alphabet, then select the desired character.

We can choose character by selecting its digit.

If we have installed both Chinese and Japanese, we can swith between them by pressing Ctrl+Shift (default, otherwise use fcitx-configtools to set own shortcuts).
If we we want return back to English, press Ctrl + Space by default.

How to write Katakana

In mozc (Japanese Input method), we can swith to katakana from hiragana by pressing F7, after we finish typing in hiragana.

Let’s show by example.

We type みるく then press F7 and Enter. We get ミルク。

That’s all.

How to type ü in Chinese input

In google-pinyin with fcitx it’s on the v key. So, just type nv and you get 女。

My Japanese/Chinese input don’t work in Qt/Gtk applications.

I had such a problem, because I had installed packages minimally with –no-install-recommends option in apt. Just check the list of all additional packages to be installed again. And make sure that the dependencies to the Gtk/Qt applications are installed. In my case, there were packages called:

fcitx-frontend-gtk3
fcitx-frontend-gtk2
fcitx-frontend-qt4
fcitx-frontend-qt5

Then i had installed them. After that, I managed to write in Firefox browser in Chinese and Japanese.