Evan Pratten
Evan Pratten
Software Developer

I am currently working with Hiragana, Katakana, and, Kanji in some projects, and needed a more reliable way to write than running some romaji through an online translator. So, this post will detail what I did to enable native inputs on my laptop. This guide is specifically for i3wm, because it does not obey system settings for languages and inputs.

Adding font support to Linux

Firstly, we need fonts. Depending on your system, these may already be installed. For Japanese, I only used vlgothic, so here in the package for it:

sudo apt install fonts-vlgothic

Language support

Im not sure if this matters, but I have seen other people do it, so why not be safe?

I am currently running a stock Ubuntu 18.04 base, which means that everything is pre-configured for Gnome. To set language support in Gnome, pull up the settings panel:

# This line fixes some compatibility issues between 
# Gnome and I3 when launching the settings menu. 
# I recommend aliasing it.
env XDG_CURRENT_DESKTOP=GNOME gnome-control-center

Gnome language settings

Next, go to Settings > Language and Region > Input Sources, and click on Manage Installed Languages. This will bring up a window where you can select a new language to install. From here, I clicked on Install / Remove Language.

Language installation panel

In this list, I just selected the languages I wanted (English and Japanese), and applied my changes. You may be asked to enter your password while installing the new languages. Once installation is complete, log out, and in again.

With the new language support installed, return to the Input Sources settings, and press the + button to add a new language. From here, search the language you want (it may be under Other) and select it. For Japanese, select the mozc variant.

Gnome's language settings are now configured. If you are using Gnome (not I3), you can stop here.

Configuring ibus

Don't get me wrong, I love I3wm, but sometimes it's configurability drives me crazy.

After searching through various forums and wikis looking for an elegant way to switch languages in I3, I found a link to an ArchWiki page at the bottom of a mailing list (I blame Google for not showing this sooner). It turns out that a program called ibus is exactly what I needed. Here is how to set it up:

Remember mozc from above? If you are not using it, this package may not work. Search for the appropriate ibus- package for your selected language(s).

# Install ibus-mozc for Japanese (mozc)
sudo apt install ibus-mozc

Now that ibus is installed, run the setup script:

ibus-setup

Ibus settings

From here, set your shortcut to something not used by I3 (I chose CTRL+Shift+Space, but most people prefer Alt+Space), and enable the system tray icon. Now, go to the Input Method settings.

Ibus input settings

From here, press the +, and add your language(s).

Configuring .profile

According to the Wiki page, I needed to add the following to my ~/.profile:

# Language support
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -d -x

It turns out that this causes issues with some browsers, so I actually put this in my ~/.profile instead:

# Language support
export GTK_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=xim
ibus-daemon -drx

Now, log out and in again to let ibus properly start again, and there should now be a new applet in your bar for language settings.

Workflow

ibus runs in the background and will show an indication of your selected language upon pressing the keyboard shortcut set in the setup tool. For languages like Japanese, where it's writing systems do not use the English / Latin-based alphabets, ibus will automatically convert your words as you type (this behavior will be different from language to language).