Inputting Japanese text in Linux and some BSDs

Table of Contents (TOC)

CentOS-8-9x, AlmaLinux-8-9x, and friends
Fedora (21-40)
Gentoo
Lubuntu and Ubuntu (14.04, 15.04-21.10)
Linux Mint (Rebecca, Rafaela, Rosa, Sarah, Sonya, Sylvia, and Ulysa)
Debian Jessie and Stretch
MXLinux
Arch Linux
VoidLinux
FreeBSD
OpenBSD
DragonFlyBSD-5.x
fcitx-fbterm
Wayland

First, the disclaimers--Japanese in Linux and the BSDs constantly improves, and parts of this page are often deprecated. If you find any errors here, feel free to send an email to scottro11[at]gmail.com.

When this page was first begun, around 2002, it was one of the few of its kind and there were far fewer distributions to follow. In many cases, you are now better off going to the main forum for your distribution, and looking for recent tutorials there.

It used to be far more difficult to get Japanese working. Nowadays, one can just go to translate.google.com, choose Japanese as the source, and begin typing phonetically, it will work like most Japanese input engines, one types for example, s-h-i on a US or other keyboard, sees the hiragana for shi, then gets kanji options by hitting the space bar.

Although this article mostly covers using Japanese in X, one can actually, with ibus-fbterm and fcitx-fbterm, and framebuffer, input Japanese in console. (There are others, but fcitx-fbterm is the only one covered here.) For a concise roundup of input methods this article gives a very good summary. It's from 2011 but still pretty accurate.

I most frequently use Japanese in an xterminal with things like vi and mutt, a browser, and an editor such as OpenOffice. Therefore, these are often the only things that I checked. In most cases, if it works in these applications, it will also work with thunderbird and the like.

The kinput2 cannaserver combination used to be the input method of choice. Then it was scim-anthy. Then ibus-anthy and after that, ibus-mozc. Then came fcitx, which is what I'll be covering through most of this article save for a few that only have ibus (e.g., RHEL9). This page will only cover fcitx5. The somewhat older fcitx is similar, though the profile file may be different.

Ibus has changed its ctl+space default to change between English and Japanese to Windows key+space. Perhaps they wanted to imitate Apple--though with Apple these days, cmd+space opens its search function unless you disable that. Possibly they decided it was harder to hit by mistake. Using ibus-setup, you can change it back to ctl+space.

Unfortunately, changing the shortcut to Windows key+space frequently conflicts with other keyboard shortcuts--for example, in dwm, if one changes the default mod key from alt to the Windows key--Fedora, among others, uses the Windows key instead of alt--Windows key+space is used to change layouts. Others have reported ibus failing to work due to some conflict with the keyboard shortcut. If one runs ibus-setup, there is a box showing the default of Windows Key (or Mod4)+space. If you click on the little box to the right of the textbox showing that, another dialog opens up, with the word Modifiers next to a few check boxes. The user can then use Control (or any other of the choices that they prefer), click apply, then OK.

The ibus page is here, but, at least for Japanese, the instructions are a bit lacking. For most of this, we're going to be using fcitx, ususally with mozc. In many cases, I have problems working with ibus in anything but Gnome, so I no longer use it.

If something's not in the table of contents, which I just added in June of 2015, it means I haven't worked with that system since 2015 or earlier. I've left in some that I haven't worked with in years, such as DragonFlyBSD.

TOC

CentOS-8x and friends

(Last update June, 2022)

RedHat and CentOS-8, have an fcitx-anthy package that can be used. If you choose the server edition, which is the default, it has a Gnome GUI, and ibus works without problem if one follows RH's article on enabling Asian language input. Note that their page says one should install @im which brings in all input managers but all you need is is ibus-kkc. This will pull in all necessary dependencies--if you're using Gnome. The RedHat article, though it doesn't mention it, is using ibus.

I prefer to use a lighter weight window manager, usually either dwm or openbox. One can install fcitx-anthy. Sometimes, you may need to start it with fcitx -d -r or it doesn't work in urxvt. (If one just uses fcitx -d it will work with firefox and other gtk apps, but not in urxvt.

There doesn't seem to yet be an fcitx-config so if using it I use what has been the simplest method for me. I startx and run fcitx -d -r. I then kill X and go into ~/.config/fcitx/profile. There is a long, long list of currently enabled input managers. all marked False. One of the first is anthy, right after the fcitx-keyboard entry. Change the anthy:False to anthy:True. Once again startx and run fcitx -d -r. Now if you hit ctl+space, you should be able to input Japanese. Again, if you use RH's preferred Gnome, you can, instead, use their article linked above. In Gnome, it works without problems.

(RHEL-8 and friends don't have fcitx5. Most of the other sytems covered below do have it).

RHEL9 and clones haven't been out that long. There is, right now, no rpm for fcitx or fcitx-anthy (or fcitx-kkc). There is an ibus-anthy available. There is a request for an fcitx package on bugzilla. The original request was from 2017, I just updated it in June of 2022, asking for fcitx for RHEL9 and friends.

There is a flathub flatpak package for fcitx5 and an addon for mozc, but I haven't tried it at time of writing. If I do, I'll update.

Even in a standard workstation install, setting up is slightly different than RHEL8. In Gnome, once you type in language, you have to click the keyboard on the left hand menu (when the language menu comes up, and choose to add Japanese and Anthy from that menu. There will be something showing English with a plus sign underneath, clicking the plus sign gives the option to add Japanese and then anthy. But the first screen shown when you select language, just shows your default language. To be able to add an additional one, you have to select keyboard and add it there.

You may have to after installing ibus-anthy, log out, and then, after logging in, go back to the keyboard and select. There should be an option for Japanese (anthy) and you can add it. This hasn't been consistent for me. RedHat has their own page on it here.

If using a minimal install, it's a bit more work. First, I use dnf to install ibus-anthy. I start openbox from a text login with startx. My .xinitrc contains the lines
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export LC_ALL=en_US.UTF-8
ibus-daemon --xim &
exec openbox-session

If I leave out the --xim, I can get Japanese in firefox and other gtk apps, but not in urxvt, my preferred terminal. I have noted, thanks to posts on Fedora Forums, that the xfce4-terminal works without having to add the --xim option. It seems to offer the benefits of gnome-terminal with less cruft. It is available from the EPEL repo.

To set it up, I run ibus-setup, and when I click input method, English shows as there already. I click add, and am given various languages, including Japanese. I click that, and anthy is shown as an option. I click add, and it's set. Only RH and clones don't have a working fcitx for their latest versions. At time of writing, there is only ibus-anthy, no ibus-kkc or ibus-mozc.

However, I suspect the average desktop user of RHEL9 and clones will run Gnome, in which case, ibus will easily work. So, until EPEL or other adds an fcitx rpm, it is necessary to use ibus.

If you are using the kitty terminal emulator, you also need to add export GLFW_IM_MODULE=ibus to .xinitrc TOC

Fedora

(Last update, February, 2024)

Fedora's workstation comes with ibus, however, we're going to use fcitx5. As we're using Fedora 39 or higher, we'll use dnf rather than yum. One has to use fcitx5.

I should mention that like CentOS and clones, if one choose the default Gnome workstation, it is probably easier to use ibus. Refer to the RedHat page mentioned above. As mentioned before, one doesn't have to do install @im just ibus-mozc which will pull in all dependencies. However, if one uses other desktops or windowmanagers besides Gnome, keep reading to use fcitx instead. As described here, as anthy has been dead upstream, libkkc was also moved into Fedora. This means that one can use fcitx5-kkc if they prefer. I use mozc, which is available.

If using Gnome (which I don't) the user can look at this page about changing the default input manager. Its information was incorrect, but hopefully has been fixed. I have the correct method below.

The steps given at the end of this section are only needed with Gnome3 itself, not Mate or Cinnamon. The Arch Linux wiki article on fcitx gives some other suggestions for using it with Gnome, but as you'll see below, it's not that big a deal. There are a couple of extra steps. I don't use Gnome, I was just surprised to hear that it was a problem, so tried it for myself. It isn't a problem with Ubuntu's Unity, Mint's various desktops, or Fedora's Mate. I didn't try with Fedora's Cinnamon but I suspect it's not an issue there either.

The first method given here also works with the XFCE and LXDE spins, as well as my preferred minimal install

I use Fedora by booting into text mode and running startx to either openbox or dwm. In such a case, the procedure is quite simple.
dnf -y install fcitx5-mozc

This should pull in all dependencies. However, note that as mentioned above in the CentOS section, if you are running a more minimalistic environment, using, for example, fluxbox, it fails to pull in dbus-x11, so you will need to install that as well with dnf -y install dbus-x11.

You will also need fonts. I usually install vlgothic-fonts, vlgothic-p-fonts, sazanami-mincho-fonts and sazanami-gothic-fonts. I also add default-fonts-cjk-mono and default-fonts-cjk-serif.

I add to my .bashrc
export LC_CTYPE=en_US.UTF-8

I boot into text mode and run startx, so I put these in my .$HOME/.xinitrc. With Fedora, while trying with the LXDE and XFCE spins, I either used the im-chooser GUI which is included with both spins, or running sudo alternatives --config xinputrc. Either method edits the /etc/X11/xinit/xinputrc which is a symlink to /etc/alternatives/xinputrc which is a symlink to /etc/X11/xinput.d/<your_chosen_im>.conf. The difference seems to be that using im-chooser does more, as if you use it, fcitx will start with your next Xsession, whereas if you use alternatives --config you will have to manually start it.

If doing it manually, as I do, insert the following to $HOME/.xinitrc above the line calling the window manager.
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx

If using the kitty terminal emulator, you also have to add export GLFW_IM_MODULE=ibus, even though you're using fcitx5. If I want it to start each time I start X, I can add fcitx5 -d -r below the export (but above the line to exec the window manager).

Now we need to edit $HOME/.config/fcitx5/profile.

We could use the GUI config too, but it's easy to do manually. Edit $HOME/.config/fcitx5/profile. If using a GUI login manager, such as with the LXDE spin, fcitx5 may already be running if you log out and log back in. Otherwise, once X is started, start fcitx with the command fcitx5 -d. You should see that it's started, but Japanese input may not work yet. Stop it with pkill fcitx.

If you start X manually with startx, then just kill it. If you use a login manager, log out, then use ctl+alt+F2 to get to a console prompt, where you can put in your username and password.

Make sure that ctl+space isn't used for anything in your window manager, because it's fcitx's default key for switching. There should now be a file in $HOME/.config/fcitx5 called profile. Edit this $HOME/.config/fcitx5/profile with your favorite text editor. Change it to read
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=mozc

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=mozc
# Layout
Layout=

[GroupOrder]
0=Default

That's assuming you're using mozc. If using anthy, put in anthy wherever I have mozc in the example above.

Go back into X, either by running startx or using ctl+alt+F1 to get to your login manager. If fcitx isn't running, start it again with fcitx5 -d -r. The -d makes it run as a daemon in the backround, the -r is for restart, in case it is running already.

If you use openbox, even if you boot into text mode and run startx, fcitx5 may automatically start running when you start X. If you don't want this, look in /etc/xdg/autostart. There should be an imsettings-start.desktop file. Near the end of the file is an Exec line that will start fcitx. You can comment out that line, or just rename the file.

As for Gnome, as it uses ibus by default, a few extra steps are necessary if using fcitx. Once fcitx5-anthy or any fcitx5 input manager, first disable ibus integration, then switch im-settings. Once that's done, fcitx gets started and we can add anthy. The first step is to run
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"

This disables ibus integration.

You should now be able to edit the .config/fcitx5/profile file. You should be able to switch between normal and Japanese input with ctl+space. If not, log out and log back in.

Although ibus will still be running, you'll be using fcitx. If you like, you can rename /usr/bin/ibus-daemon to something like /usr/bin/ibus-daemon.bak. This will stop it from running and in my brief test with Gnome, didn't break anything. Don't remove ibus as that will break Gnome.

Apparently, in Wayland, which is now the default in Fedora's Gnome, the export lines (for XMODIFIERS, GTK_IM_MODULE and so on) should be either added to /etc/environment or /etc/profile. The information is from the Arch wiki.

With an install of Fedora and Gnome that was running Wayland, however, I didn't have to add in the variables, it just worked.

However, when I tried labwc, a window manager that is supposed to run like openbox but in wayland, putting them in /etc/profile didn't work. It did work if I put the environment variables in ~/.bashrc and started terminals from their equivalent to dmenu, bemenu. Later I learned they should go into $HOME/.config/lawc/environment. In short, if using Gnome, once you set it up, as described above, neither Gnome nor openbox required me to put the variables anywhere, it just worked as soon as I started fcitx5. With both Gnome and openbox, I had to start it manually with fcitx5 -d. Before Wayland, one could simply use imsettings-switch fcitx, but it doesn't work with Gnome and wayland, and, to be honest, I don't use Gnome enough to research a fix. I just wanted to check how to get fcitx working with Gnome in F34 which was the last time I tried it with Gnome.

TOC

Gentoo Linux

(Last update, December, 2017)

Gentoo has its own pages on Japanese, fcitx, and urxvt, my terminal of choice, and much of this is gleaned from those pages. Gentoo's own pages are slanted towards ibus.

You'll see I add the xft USE flag to rxvt-unicode. When I didn't, it gave me issues, such as inputting Japanese but then showing blank squares. Rather than font-hunting I emerged again with the xft USE flag and everything worked. Also, if you choose to specify fonts in .Xdefaults, It's a lot less typing if you use xft.

So, when installing urxvt (which is one of the first things I do anyway, as it's my terminal of choice), include the xft USE flag.
USE="xft" emerge rxvt-unicode 

One font that works well with it is the TTF ipa-mincho font.
emerge ja-ipafonts 

You will also need dbus and we are using fcitx-anthy. There isn't an ebuild for fcitx-mozc, and I didn't try to get it working as an input method.
emerge sys-apps/dbus

The sys-apps part may be unnecessary, but won't hurt and at one point there was also a haskell-dbus. The last time I tried this, I forgot it with no ill effects, but things can always change.

We want gtk and qt4. If you don't have them as default USE flags, temporarily enable them for this.
USE="gtk qt4" emerge fcitx-anthy

It may be necessary to add lines to /etc/portage/package.use. For example, at one point I got a message that I had to add =x11-libs/cairo-somenumber X. If you're not familiar with package.use, it's a file under /etc/package. Sometimes, a directory containing files. In that case, I just added the line
x11-libs/cairo X

to /etc/portage/package.use. In my case, there was already a directory, not a file, called package.use, but I just renamed it with no ill effects. It had a file called iputils so I kept that in case it was needed again. This probably isn't best practice, but it worked. See the wiki section on package.use The last time I did this, however, that wasn't necessary.

The emerge may take quite awhile, especially if this is your first time with gtk and/or qt4 USE flags.

Add the following to .xinitrc if you use startx or SLIM and .xprofile if you use GDM, KDM, or LightDM.
eval "$(dbus-launch --sh-syntax --exit-with-session)"
export XMODIFIERS="@im=fcitx"
export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx

Again, if using the kitty terminal emulator, also add export GLFW_IM_MODULE=ibus.

If you didn't put in the USE flags for gtk and qt4 than the GTK_IM_MODULE and QT_IM_MODULE should use xim instead of fcitx. So, change your .xinitrc (or .xsession)
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim

Now, startx and start fcitx. Once it's running, kill X and edit $HOME/.config/fcitx/profile. Look for where it says anthy:False and change that to read anthy:True. Then start X again and it should enable you to input Japanese in applications that allow it.

If, for some reason GTK or QT apps aren't allowing you input Japanese, try changing their input module to xim. You can do this on the command line
GTK_IM_MODULE=xim libreoffice

If that works, it means you may have forgotten or mistyped when trying to emerge them with gtk and/or qt4. You can either emerge again, this time being careful to either add the USE flag at command line or in /etc/portage/make.conf, or just change your GTK_IM_MODULE and QT_IM_MODULE lines to read xim instead of fcitx. (Leave the XMODIFIERS line alone).

(You can also use /etc/portage/package.use but I find one of the other two methods quicker for me.)

While it's not necessary, (unless you have some oddity and urxvt is not properly displaying fonts), you can use this in your .Xdefaults.
URxvt*font xft:IPAMincho:size=12

This works for me, the reader may have other font and font size choices.

After starting X, you can start fcitx with fcitx -d -r.

With some window managers, such as openbox, it may autostart.

TOC

Lubuntu and Ubuntu

(Last update December 2021, Lubuntu 14.04, Lubuntu 15.04-17.10, Ubuntu 15.04, Ubuntu 16.04, Ubuntu 17.10, Ubuntu 20.10, Ubuntu 21.10)

For Lubuntu 15.10, fcitx is the default input manager. First add Japanese language support by going to Preferences=>Language Support, picking Japanese by clicking the checkbox by it, then clicking Apply Changes. This will download some additional language packs. Install fcitx-mozc.
apt-get install fcitx-mozc

The dialog box opened when you choose Language Support (that you used for installing Japanese support) has a line for Keyboard input method system, set to none by default. Click the dropdown box and choose fcitx. Log out and log back in, and you'll see a little box on the bottom bar, with the letter a.

Choose Configure Current Input Method. In the box that opens, uncheck the box saying Only Show Current Language. Scroll down to Japanese and if you click on it, it should expand, showing mozc as a choice. Click on it. There isn't an Ok or any indication that it's saved your choice, but once you close the dialog box, if you hit ctl+space you will be able to enter Japanese.

Prior versions of Lubuntu come with ibus already installed, but it's easy to switch to fcitx. This is what I did on 14.04 and 15.04
sudo apt-get update
sudo apt-get install fcitx-mozc
im-config

When you run im-config, the first message tells you that you should only have one input manager installed. While you can uninstall ibus, I've found it unnecessary. In the next window, they ask you if you're sure you want to reconfigure. Choose yes. In the next screen you can choose fcitx as your input method.

Log out and log back in. When you do, there will be a little keyboard on the bottom task bar. Right click and choose configure input method. Click the plus sign at lower left. Uncheck the box that reads only show current language. The box below it is the search box, type mozc in there. In the top textbox, you should now see mozc Japanese, and, once you highlight it, you should be able to click the OK button. Do it and close the window.

You should now be able to switch between English and Japanese with the ctl+space keyboard combination.

To do this with Ubuntu, using Unity, it's almost the same. The keyboard icon will be on the upper right taskbar instead of the bottom right, and I think the menu says Configure current input method instead of Configure input method, but otherwise, the steps are the same.

Lubuntu 16.04 is a bit different. Go to Preferences and choose Language Support. Add Japanese, which should install fcitx-mozc. Make sure that it has, otherwise, install it with apt-get install fcitx-mozc.

Also in the language settings box, there should be a keyboard input method section. Make sure it says fcitx--it may say none by default.

Log out, log back in, you'll see the keyboard icon. Click the Configure Current Input Method.

Typing mozc in the search box gave me no results. After unchecking Only Show Current Language, I had to scroll down to Japanese. This had a little arrow to the left. Clicking that arrow showed me mozc. I then highlighted it with the mouse, and now had to click a rightwards pointing arrow to put it in the right hand pane with a header of Current Input Method, under English, which was already there. There was no way to close the Input configuration window so I closed it with alt+F4. I could then input Japanese with ctl+space.

With Ubuntu Unity 16.04, when I first opened settings to add and remove a language, ibus was shown as the default. I chose to add Japanese, and that automatically installed fcitx-mozc. When it was completed, I closed the language window and reopened it. This time, fcitx was available as an option.

Log out, log in, and there is a small keyboard icon on the upper right. Click it, once again choose configure input method, uncheck the option to show current language, type in mozc, which should show up. Click Ok and you should be able to use Japanese in most applications by hitting ctl+space.

With Lubuntu 15.10, once Japanese was set up, I could use another window manager such as dwm and easily change between English and Japanese with ctl+space. I haven't checked with 16.04

For those who want to use fcitx-mozc in 12.04, there is an unstable ppa at https://launchpad.net/~fcitx-team/+archive/ubuntu/nightly. To add it, run
sudo add-apt-repository ppa:fcitx-team/nightly

You can then run apt-get update;apt-get install mozc-fcitx im-config. From there, the instructions are the same as they were for Lubuntu above. Run im-config, choose fcitx, Log out, log back in, click the little keyboard, choose configure input method, uncheck show current language, type mozc in the search box, and when it appears up top, click OK. In a very quick test, it worked in LX terminal, Chrome and Abiword.

I repeat that it is an unstable ppa, so use at your own risk. The stable ppa doesn't have the fcitx-mozc or fcitx-anthy package.

Lubuntu 17.04 and 17.10 are very much like 16.04. Go to preferences, choose language support. You may get a notice that language support is not completely installed, click remind me later.

Click install / remove languages. Select Japanese, click apply, and put in your password. Once it's instsalled, the first window that showed up is still open and has a drop down box for keyboard input, choose fcitx.

Selecting Japanese should install fcitx-mozc, you can always check with a terminal command dpkg -l |grep fcitx-mozc. It should list it with ii in front of it, meaning it's installed. (If not install it with apt-get install fcitx-mozc).

Log out and log back in. You will now see a keyboard icon to the lower right. Click it and it should give you the option to Configure Current Input Method. Click that and a window opens. Uncheck Only Show Current Language.

In the list of languages that appear, click on Japanese and a little arrow will appear to its left. (Or said arrow may already be there). Click it and one of the choices will be Mozc. Highlight and click the arrow to the right which should put Mozc into the right hand pane of the window.

Close the window and you should be able to input Japanese, toggling between Japanese and English with ctl+space.

There are almost always updated tutorials on using Japanese in Ubuntu on the Ubuntu Forums and the reader can always look for the latest tutorials there.

Ubuntu-17.10 has gone back to Gnome which uses ibus by default. If one googles ubuntu-17.10 ibus you'll see some complaints about this, but, like other distros using Gnome, one can use fcitx if they wish. These instructions have been tested as late as Ubuntu-21.10

Note that like RH and Fedora, it may be easier to use ibus. In that case add the language as mentioned above and run ibus-setup. You should be able to take defaults. Sometimes I've found that I have to restart to get it all working, but in the end, if you leave it at defaults the super (Windows) key and space will change input method from English to Japanese. You may have to click the letter icon on the top right once or twice to change back and forth, but after that it's just worked for me, as long as I use Gnome.

Even with Ubuntu, I tend to prefer alternative desktops and fcitx works across a wider range of them for me. So, assuming you want to use fcitx the following should work.

Disassociate it as we do in Fedora.
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"

Install fcitx-mozc with apt-get install fcitx-mozc. Now, run im-config. This opens a dialog, with the first page showing the possible choices and showing ibus as the default. Click Ok. The next page asks if you explicitly select the user configuration, recommending a choice of no, but choose yes. The next page lists several choices, including fcitx. Click the radio button to its left. The next page lists the choice, saying to restart X. I've found it simplest to just reboot. as otherwise, the change didn't seem to stick.

Run fcitx-configtool. Click the plus to add a language, uncheck the only show current language and type mozc in the search box at bottom. It should appear at top. Highlight it, click OK and another box should show, showing mozc. Close the box. You should now be able to input Japanese.

TOC

Linux Mint

(Last update December 2020)

With Mint's Rebecca, once logged in, in the start menu search for languages. Click the Install Remove Languages button and choose Japanese, Japan UTF-8. (You'll be asked for your sudo password once or twice during this)

Japanese will then show as an installed language, but show that some language packs are missing. Click on it and you'll have the option to install them. Once it is showing as fully installed in the list of installed languages window, when you close that window, you'll see a window for input methods in 17.1.

Choose fcitx. Once it's installed you can ignore the button for optional components, but use apt-get to install fcitx-mozc from a terminal. You'll also remove fcitx-qimpanel, otherwise, when we get to the input icon, it will be in Chinese. After doing this, if you go back to the input manager menu for any reason, it will show that fcitx has a missing component. This refers to the qimpanel and can be ignored. If you're using XFCE, it may not be necessary to remove qimpanel, as when I tried this with its XFCE edition, the icon gave me an English menu.
sudo apt-get install fcitx-mozc
sudo apt-get remove fcitx-ui-qimpanel

Once this is installed, log out and log back in. In the lower right, you will a little keyboard icon. If you right click it, you will see a menu. In Mint's case, you can either use Config or Configure Current Input Method, it will open the same menu.

From here, it's just like Lubuntu and Ubuntu. Click the plus sign at lower left. Uncheck the box to only show current languages and type mozc in the search box. When it appears in the upper box, highlight it and click OK. Close the dialog box and you should now, in any application that accepts Japanese input, be able to hit ctl+space and you'll see a little box that says mozc. You will then be able to input Japanese.

With the XFCE edition, I installed fcitx-mozc, then restarted fcitx. When I went to configure current input method, mozc was already there.

17.2 was slightly different. I've only worked with Cinnamon. After installing Japanese and its language packs, one just clicks a different tab to get to input methods and install fcitx. Then install fcitx-mozc with apt-get install fcitx-mozc. Log out and log back in.

17.3 went back to closing the add languages window and seeing a window for input methods.

My results haven't been consistent. Sometimes, there was no qimpanel icon, other times there was. So, do the apt-get install fcitx-mozc, apt-get remove fcitx-ui-qimpanel, log out and see if there's a keyboard icon on the lower right.

If there is, do it the way we've done it in 17.1, if not, open a terminal and run
fcitx-configtool

This opens up that same dialog box that has been mentioned, for input method configuration. As we have in each case, click the plus sign at lower left, uncheck the box to only show current language, type mozc in the search box and when it appears in the top box, highlight it and click Ok. You should now be able to hit ctl+space and input Japanese.

In at least one test install, I didn't even have to do this. I installed fcitx, logged out, logged back in to see no qimpanel, then installed fcitx-mozc. Upon installation, without running the config tool, as soon as it was installed I was able to input Japanese. I don't use Mint enough to keep testing, but to sum up, if, after installation, the little keyboard icon doesn't appear, you may be able to input Japanese as soon as you install fcitx-mozc. If not, then you can run the fcitx-configtool command and be able to add mozc, then use it.

I've also found that if I want to use dwm in Mint for whatever reason, the easiest way to get it working with fcitx is to create a $HOME/.xsession file reading
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
fcitx -d -r 
exec dwm 

I haven't used the kitty terminal emulator in Mint, but I suspect you will need the export GLFW_IM_MODULE=ibus for it to work. and then in 17.1, choose, from the login choices, the Run XClient Script option. Judging from many posts on Mint Forums, few Mint users realize what that does--it looks for a $HOME/.xsession, so is one easy way to add custom window managers. The other way is to go into /usr/share/xsessions, copy one of the existing *.desktop files to say, dwm.desktop and substituting your window manager for the one in the file you copied. However, again using dwm as my example, though this would start dwm, it wouldn't start fcitx or use the variables that I'd set. Therefore, I used the Run Xclient script with the $HOME/.xsession mentioned above.

The Run Xclient script is gone from 17.2. One can still create a $HOME/.xsession, and then create a /usr/share/xsession/dwm.destop pointing the Exec line to your $HOME/.xsession. You will, if doing this, have to make the $HOME/.xsession executable with chmod 755 $HOME/.xsession. You can do that in 17.1 too, of course, but it's less typing to just create the $HOME/.xsession and use Run Xclient

The /usr/share/xsessions/dwm.desktop should read (if your user name was john
[Desktop Entry]
Name=dwm
Comment=use dwm
Exec=/home/john/.xsession
TryExec=/usr/local/bin/dwm
Type=Application

There's an Icon line that you can leave blank or remove.

With openbox, it would start fcitx but not use the variables. I just copied my $HOME/.xsession to $HOME/.xsessionobox, and changed the exec dwm to exex openbox-session. I then edited the /usr/share/xsession/openbox.desktop that had been created when I installed openbox. By default it reads

[Desktop Entry]
Name=Openbox
Comment=Log in using the Openbox window manager (without a session manager)
Exec=/usr/bin/openbox-session
TryExec=/usr/bin/openbox-session
Icon=openbox
Type=Application

I changed the Exec line to read
Exec=/home/scottro/.xsessionobox

I then changed the permissions on my $HOME/.xsessionobox to 755 and then, if I chose openbox, it would have the proper variables set.

Most of this also worked for Ulysa. I used the xfce4 version, installed openbox and did this in an openbox session. I created an .xsessionobox, then set /usr/share/xsession/openbox.desktop to use /home/scottro/.xsessionobox.

Also, with Ulysa, after installing fcitx-mozc, I had to log out and log back in for fcitx-configtool to find mozc. (Also, fcitx has to be running, I just did that from command line, running fcitx -r -d).

However, on one install of Ulysa, on my yoga2, to get openbox to read the environment variables, adding them to $HOME/.xsessionobox didn't work. I had to add them to /etc/X11/openbox/environment. Once I put the XMODIFIERS and other variables in that file (you need to do it using sudo), openbox used them.

If you'd rather not do something like that and just need the variables set when you run particular programs, use a script similar to the ones mentioned above. Calling it something like jp.sh put it in $HOME/bin directory, and have it read
#!/bin/sh
XMODIFIERS=@im=fcitx GTK_IM_MODULE=fcitx QT_IM_MODULE=fcit ${1+"$@"} &
and call whatever needed with it, e.g., jp.sh firefox or jp.sh gnome-terminal. The reader can use what method works for them, but, at least judging from Mint forums and conversations with friends and co-workers who use Mint, most of them stick with the default desktop.

One other oddity with 17.2 Rafaela and openbox. The openbox menu opens gnome-terminal with a black background and black foreground so that it's not readable. This can be fixed by right clicking inside the terminal, going to Profiles, Profile Preferences and clicking the Colors tab.

With LinuxMint 18, Sarah, there are few changes. In the Mate version, I typed Language into the menu search bar, and opened Language Settings. I clicked Install/Remove Languages. Click the Add button and choose Japanese,Japan UTF-8. Click install. Close the Add language window and you should see Japanese is now installed, albeit with a message that some language packs are missing.

Closing that window goes back to the Language Settings window. Click the Input Method tab. You will see Fcitx with a line underneath saying not installed. Click the Add Support for Fcitx button.

There's an option to install the additional components, but that seemed to have a lot that I didn't want. So, I then opened a terminal and ran
sudo apt-get install mozc

I then logged out, and logged back in. (That may not be necessary). I now did a search for fcitx in the menu and had an option to start the input method. When I did that, a keyboard icon appeared in the lower right. Right clicking that gives an option to configure current input method. Click the plus sign and unclick the Only Show Current Language checkbox. Type in mozc, it should appear at the top, and click OK. At this point, you should be able to input Japanese with the usual ctl+space trigger.

. I didn't check how to make it automatically start at each log in. Instead, if I needed to use it, I would just type fcitx in the menu search and click the start fcitx button.

Mint 18.2, Sonya, using Cinnamon is almost the same.

  1. Type language into the menu search bar and click Languages.
  2. Put in password when requested.
  3. Click the add button at the bottom left of the window that opens.
  4. Choose Japanese_Japan UTF-8. Click Install. It now appears in languages.
  5. Close that window. Click the Input Method on the window that you now see. Click the install button on Japanese.
  6. Enter password and it will show that it's downloading. When done, it will show installed with a note to choose Fcitx or ibus.
  7. In the top section, click the dropdown box next to input method and choose fcitx.
  8. Close the window (there's no save or OK button.) Log out and log in.
  9. You will now see a new icon on the lower right, a penguin. If you click it, it may turn into a keyboard. Open a terminal and type in
    fcitx-configtool
    

  10. Click the plus sign at lower left. Uncheck the box that says Only Show Current Languages.
  11. Type mozc in the search box and it should show up at the top. Click Ok, and close the dialog window
You should now be able to toggle between Japanese and English with ctl+space.

The instructions for Sonya also work for 18.3, Sylvia, Mate edition. (I think one of the input buttons was named differently.)

TOC

Debian Jessie and Stretch

(Last updated July, 2017)

Once you have X working, install fcitx-mozc. If you have your install set to not install recommended packages, unset that. (For example, I have that set in /etc/apt/apt.conf, so before installing fcitx-mozc, I comment that line out.) It will pull in quite a few packages, but I've never figured out what is and isn't necessary.

Also install dbus-x11 if it's not installed.

I add to my $HOME/.bashrc file
export LC_CTYPE=en_US.UTF-8

I also insert the following in my $HOME/.xinitrc, before the line calling my window manager (usually dwm or openbox)
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx 

Again, I've not used kitty with Debian but I assume you also need the export GLFW_IM_MODULE=ibus for kitty to show Japanese.

If you boot into a GUI, I'm not sure where that would go. It can always go into your .bashrc, but it's better to put it into a file read when X starts, which may depend upon your window manager. Some window managers, such as openbox, will automatically start fcitx when you run startx. If you don't want this, you can look in /etc/xdg/autostart and rename the file. If you're running a different window manager such as dwm, that doesn't automatically start it, and want it to start whenever you start X, you can have fcitx start whenever you startx by putting, also above the line calling your window manager
fcitx -d -r

into your .xinitrc.

The -d as mentioned makes it a background daemon, the -r restarts it if it was already running.

We need fonts, This is what I use. The reader of course, can use others.
apt-get install ttf-kochi-gothic.

Now you should be able to run fcitx-configtool. It opens up a dialog box (like Fedora, and also basically what you see when you click the config menu in Ubuntu or Mint). Click the plus sign at lower left to add a language. Uncheck the box to only show current language and type mozc in the search box. It should appear in the upper dialog box. When it does, click Ok, and you're returned to the main dialog window. Close it. I haven't noticed a close menu, I just close it with alt+F4 in openbox--use your window manager to close the dialog window. Now, if you hit ctl+space in any application that accepts Japanese input, you should see a little box saying mozc.

This can also be done manually with the following method. Once you've started X, run fcitx with no arguments for a moment. Then you can kill it with ctl+c. This will create (if it wasn't already there) a $HOME/.config directory which will now contain an fcitx subdirectory. Kill X and while in console edit $HOME/.config/fcitx/profile. It has very long lines, and may show as 10-20 lines and a bunch of @ symbols. Do a search with your editor's search function for mozc. You'll see it says mozc:False. Change that False to True. Now startx and make sure that it still says True. (It should as long as you killed X before editing the file. Killing fcitx doesn't seem to be enough.) Now, if you haven't started fcitx in your .xinitrc file, you can manually start it with fcitx -r -d. Once back at a command prompt, hitting ctl+space should give you a little box saying mozc and you should be able to input Japanese.

Debian-9, Stretch, is similar. Instead of kochi fonts which didn't seem to be available, I let fcitx-mozc pull in some fonts, such as vlgothic. Make sure dbus-x11 is installed before starting X, and start fcitx -d -r before running fcitx-configtool. Otherwise the instructions are the same as they are for Jessie.

TOC

MXLinux Fluxbox edition

(Last update July 2023)

First, once you're an X session, install fcitx-mozc. Root privilege is required, in the example, I'm using sudo.
sudo apt install fcitx-mozc

Next, click on the Software icon on the desktop. (A downward pointing arrow and plus sign). It will ask for your sudo password. From the menu that appears once you've authorized, click the arrow next to languages, which opens a whole list of language related packages. It's in alphbetical order, so scroll down to Japanese. I selected everything for Japanese, the packages are for Japanese Firefox, Fonts, Input, Input_fcitx, Libreoffice, and Thunderbird. Click install and let MXLinux install the packages.

I then added the usual variables to my $HOME/.fluxbox/startup since it uses lightdm to boot, and it wouldn't read what I put in .xinitrc. So, in $HOME/.fluxbox/startup I have
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export LC_CTYPE=en_US.UTF-8

If you really want to add those lines to .xinitrc instead, and boot into text mode you can manually edit /etc/inittab. By default, MXLinux uses SysVinit and you can change the id:5:initdefault line in /etc/initab to
id:3:default

Then MXLinux will boot into text mode, you can run startx and it will read .xinitrc, enabling Japanese in applications. But most people will probably prefer editing $HOME/.fluxbox/startup.

TOC

Then, I started fcitx from the drun menu that appears when you hit the Mod4 (usually Windows key on a PC keyboard), and I could input Japanese. I didn't even need fcitx -d -r, just fcitx worked. If it doesn't work for you, then try it with fcitx -d -r

ArchLinux

(Last update February, 2024)

ArchLinux has packages for fcitx5-mozc. The wiki article mentions installing fcitx-im and choosing all, which will install fcitx-gtk2, gt3, and qt4 but I didn't need it for the apps I used, urxvt, firefox, google-chrome-stable, and libreoffice.

Install with pacman
pacman -S fcitx5-mozc 

Install fonts. I use the noto-cjk fonts.
Pacman -S noto-fonts-cjk

Once installed, setup is similar to the Fedora setup. Like Fedora, this can be done manually. Start X then start fcitx5. Then kill X. This should create a $HOME/.config/fcitx5 directory. In there you will find a file called profile. Open it with your favorite text editor (while not in X).
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=mozc

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=mozc
# Layout
Layout=

[GroupOrder]
0=Default

Set the XMODIFIERS and various IM_MODULE variables in in .xinitrc, before the line calling your window manager. For example, if using dwm
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx
exec dwm
If you will always be using it, you can also start it in your .xinitrc file.
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx
fcitx5 -d -r 
exec dwm

The -d starts it in the background and the -r just restarts it if a desktop environment had already been running it.

If only using it on occasion, then start it from a terminal, dmenu or whatever you use, with fcitx -d -r.

Again, if using kitty as your terminal emulator, also add export GLFW_IM_MODULE=ibus.

Once you've started X, applications that accept Japanese input will work once you hit ctl+space. If gtk apps aren't working, make sure you installed fcitx5-gtk2 and fcitx5-gtk3. If you're using qt apps as well, such as libreoffice, be sure to install fcitx5-qt with pacman -S.

I've found that if use GTK_IM_MODULE=fcitx instead of xim, that firefox and other gtk apps may not work with Japanese.

TOC

VoidLinux

(Last update February 2024)

As of February, 2024, and probably earlier, Void has fcitx5-mozc. So install it and get fonts as well. So install with
 
xbps-install -Sy fcitx5-mozc noto-fonts-cjk

which should pull in most things needed. Like others mentioned here, to get firefox working, your .xinitrc should have export GTK_IM_MODULE=xim. The $HOME/.config/fcitx5/profile should read
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=mozc

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=mozc
# Layout
Layout=

[GroupOrder]
0=Default

As with other sytems, one runs fcitx5 -d to use fcitx5-mozc.

If you need fonts, Void has the noto-fonts-cjk package. Install it with xbps-install -S noto-fonts-cjk.

I've not used kitty on Void yet, but I assume you also need the export GWFW_INPUT_MODULE=ibus for it to work with Japanese. TOC

FreeBSD

(Last update February, 2024)

FreeBSD has been the same for several versions, but I'm just covering FreeBSD-14.1, the RELEASE version at time of writing. Note that now fcitx5-anthy is available. For those who prefer it, you can just install, with pkg, ja-fcitx5-anthy. If you want it to work with libreoffice, you also have to install fcitx5-qt5. The pkg-message suggests using GTK_IM_MODULE=fcitx/xim however, I've found that in my .xinitrc, where I set these variables, that what you actually need is export GTK_IM_MODULE=xim. This is needed if you want to use Japanese in firefox.

I've also found, that on a couple of test installs, I simply could not get libreoffice or other qt apps, such as the lightweight featherpad, to work with Japanese, unless I edited my .xinitrc. My usual .xinitrc will have exec openbox-session or exec dwm, depending upon which window manager I'm using. On one laptop install and one VirtualBox install, qt apps wouldn't work, unless I changed my .xinitrc to read, (this is with openbox, but the same with dwm)
exec dbus-launch openbox-session

I'm not sure why, as dbus was running, and I didn't have to do this on my main workstation, but at any rate, that's how I could get it to work with qt based applications, if they weren't working. It also isn't necessary if using xfce4. (Or probably any desktop environment, but I only checked with xfce4.) On the installs where qt apps weren't working it was the same whether I used openbox, dwm, or fluxbox. Each window manager had to be called with exec dbus-launch <desktop_name>

And yet, this isn't consistent. Another test install didn't work with QT apps when I used dbus-launch, but worked with QT when I didn't add the dbus-launch part. This is on a machine which also has a VirtualBox install. On the VBox install, I need the dbus-launch, on the actual workstation install not only do I not need it, but it breaks using fcitx5-anthy with QT apps. So, at this point, I would say, try normally, and if it doesn't work, try adding dbus-launch <window_manager> in your .xinitc.

Also, I've found that FreeBSD's included vi, which is actually a version of nvi, wouldn't input Japanese. If I hit control space and input characters they show up in the little converter window, but when I hit enter, they don't show up in the file I'm working on. However, it works with vim, though not with vim-tiny, which does the same as vi, shows the conversion, but won't write it to screen.

As with other systems, if using the kitty terminal emulator, you also have to add export GLFW_IM_MODULE=ibus to whereever you set your environment variables.

If you look at the Wayland section (or even if you don't) on the same installations that gave me trouble with QT apps in a window manager, I had the same issue with the Wayland equivalents, labwc, an openbox replacement. I'd have to start it with dbus-launch labwc to be able to use Japanese in QT applications. In the Wayland section, I mention putting the environment variables in $HOME/.config/labwc/environment, however, even doing that, I couldn't get labwc to work with Japanese in GTK applications, only (if I started it with dbus-launch), urxvt and libreoffice.

With fcitx (as opposed to fcitx5), the easiest way I've found to configure it is to startx, then run fcitx -d. Stop X, and in your $HOME/.config, there should be an fcitx/profile file. This should have a long list of input managers, and one should be mozc. It will read mozc:False. Change the False to True, save the file, and staart X again. Once again, run fcitx -d, and you should be able to input Japanese. If not, you may be able to get it working with the package zh-fcitx-configtool, but, as I've not needed it, I haven't tried it. It may also be necessary, if using the older fcitx, to install fcitx-qt5 to get libreoffice to work. My results haven't been consistent.

Sometimes, you will have to go through running startx, running fcitx -d, then closing X and looking at the .config/fcitx/profile a couple of times before that long list of input methods shows up, but again, I've not had to deal with it in awhile.

The older version of fcitx is available with mozc. If you'd prefer that, do pkg install ja-fcitx-mozc, but I'm mostly covering fcitx5. This is a reason to use the older version, fcitx5 only has anthy, but the older fcitx has mozc.

I should also mention that on a couple of installs, I was unable to get fcitx5-anthy to work with Firefox and other GTK apps. This has not been consistent, so I may have overlooked something, as there were other times when it worked. But, if you've installed fcitx5-anthy and can't get Japanese in GTK applications, I'd recommend removing it and installing fcitx-mozc.

I install various fonts--the reader can choose their own, I usually install font-sazanami, font-kochi, font-vlgothic (all in /usr/ports/japanese) and x11-fonts/hanazono-fonts-ttf.

If using pkg it's pkg install ja-font-sazanami, ja-font-kochi ja-font-vlgothic hanazono-fonts-ttf. The noto fonts are also popular.
pkg install noto-jp

There are several other packages that use noto fonts, such as noto-emoji. Running pkg search noto will show what is available.

One oddity, is that on some installs, urxvt wouldn't show Japanese. It didn't give anything. I could hit ctl+space, characters would appear, but when I hit enter, the terminal stayed blank. I then reinstalled from ports (I'd installed with pkg the first time), it added in a few packages from Chinese, and then everything was fine. However, on another install from pkg, that definitely didn't have these Chinese packages installed, I didn't have that problem. I only mention it in case the reader has a similar issue--if urxvt isn't displaying Japanese, try reinstalling it from ports. If that still doesn't work, the other issue I've found is that it may not work if LC_CTYPE isn't specified. So, on some installs, I have had to insert

export LC_CTYPE=en_US.UTF-8

to $HOME/.xinitrc, above the line calling the window manager.

The message after installation, readable with pkg info -D -x fcitx5-anthy tells you to add variables and commands to start fcitx to your .xinitrc file (or .xession, if you use that.) It suggests adding
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx/xim
export QT_IM_MODULE=fcitx

I've found, if I do that, firefox wouldn't work with Japanese, it had to be GTK_MODULE=xim, not fcitx/xim.

Also, make sure that your window manager or desktop environment isn't using ctl+space for anything, as that is fcitx's default key combo to switch between Japanese and English. I've never tried to change it, but I believe you can do so in $HOME/.config/fcitx5/conf.

There is a package, fcitx5-configtool. I've not used it, as it's so easy to do manually. While X is not running, edit your $HOME/.config/fcitx5/profile to read
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=anthy

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=anthy
# Layout
Layout=

[GroupOrder]
0=Default

Start X, run fcitx5 -d, and you should be able to input Japanese when you hit ctl+space.

Actually, if one installs the package, there are instructions on how to run it when ever X starts, which can be viewed with pkg info -D fcitx5.
cp /usr/local/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart/

This may only be for desktop environments, as it hasn't worked for me with openbox or dwm, though you can certainly add fcitx -d to your $HOME/.xinitrc file. (Before the line calling the window environment, which has to be the last line.) If you do use that, note that you'll have to create a $HOME/.config/autostart directory if it doesn't exist.

Although I'm no longer using ibus-mozc in FreeBSD, I'm leaving in this next part because it was a lot of work. I went through it back around FreeBSD-10, but it may still be the case. (The work involved is one of the reasons I've switched to fcitx. I've found similar issues in Fedora)

In FreeBSD-10, with openbox, fluxbox, dwm, and spectrwm, it was more difficult to get ibus-mozc working as I wish. It seems to ignore the keyboard shortcut I use in ibus-setup. I usually use ctl+space, but I had the same problem regardless of keys chosen.

In openbox, I use tint2 as taskbar, which is how I discovered the following workaround. In tint2, upon startup, one sees an icon for input method. It says (in my case) US by default. Clicking on it, I was able to change to mozc. I then see a submenu that is at direct input by default. If I click that to use hiragana as the input method, everything works. This may have to be done with every log in. Some very casual testing indicated that the icon would stay at mozc, but that I would manually have to set input to hiragana every time between X sessions and that it reset to US between reboots.

Once this has been done, (at least for the particular X session), one is able to use whatever hotkeys they chose in ibus-setup, ctl+space in my case.

To get it working properly in dwm or spectrwm, where I don't use tint2, I have found that although it's a bit kludgy, the easiest way to get it working will be to briefly open up tint2.

If you don't have a $HOME/.config/tint2/tint2rc it will fail to start. You can copy that over from /usr/share/examples/tint2. (The .config/tint2 directory will be created the first time you try to run tint but the it's quicker to prepare).
mkdir ~/.config/tint2
cp /usr/local/share/examples/tint2/tint2rc ~/.config/tint2

As previously mentioned, the tint2 bar will show a language icon. If you click it to get to mozc, there will be a submenu to choose input. Choose hiragana, and it should work on applications that support Japanese input. On FreeBSD-10.x, I could use it in gnome-terminal, but it took a reboot to get it working in urxvt. Once it starts working in say, dwm, where I don't normally want tint2, I can close tint2 and it will continue to work with my ibus hot-keys of ctl+space to switch back and forth between input methods.

This works with every test I've made with a single monitor. Prior to stumbling upon this solution, user byuu on FreeBSD forums, wrote a little script to get it working. See this thread on the forums for extra details. The script mentioned below is from byuu.

This script is the only way I've been able to use multiple monitors without making every change to input by mouseclick.

When doing so, I can ignore the ibus hot keys in ibus setup. Instead create hotkeys, through the window-manager, to a script that does the change. Here is what I did with openbox. Although instructions in the ibus pkg-message suggest adding a few more things to one's .bashrc (or other shell rc file), I've only needed the following.
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export LC_CTYPE=en_US.UTF-8

Next, create a small shell script. I put it in $HOME/bin, the script can go anywhere in your shell's $PATH. (If that doesn't mean anything to you, don't worry about it. Make a directory in your home directory, called bin, if it doesn't already exist, and put the script in there.) In this case, I'm using mozc. If you prefer to use anthy, just substitute anthy for mozc-jp in the script.
#!/bin/sh
if [ `ibus engine` = 'mozc-jp' ]; then
  ibus engine xkb:us::eng
else
ibus engine mozc-jp  #or whatever IME you prefer; change it above too.
fi

Note that those are backticks around ibus engine, not single quotes.

Name it somehing like imswitch.sh, and make it executable.
chmod 755 ~/bin/imswitch.sh

Now, in ibus-setup, the default is super+space. As testing has indicated that regardless of what I've set for the hotkey to switch input, it gets ignored, you can leave it at that, the script is going to perform the function of switching input methods. Lastly, in openbox, I added a stanza to link ctl+space to the script. My $HOME/.config/openbox/rc.xml file contains
<keybind key="C=space">
<action name="Execute">
<command>imswitch.sh</command>
</action></keybind>

Now, using ctl+space will switch between English and Japanese.

in DWM, I made a different keyboard shortcut to the script, having nothing to do with either super+space or control+space. The little script takes over and does the switching. In openbox, through xdg, ibus is started when one runs startx. In dwm, I would manually start ibus with
ibus-daemon --xim &

Once ibus is started, the default input is Japanese. So make sure you can get to your script to switch back to English, otherwise, you'll be unable to type commands. If you have a keyboard shortcut to dmenu, that will work, as dmenu, at least in my tests, would use English input--therefore, if I was in dwm and couldn't input English, I was able to use a keyboard shortcut to open dmenu, and type imswitch.sh in as a command, At that point, I was again able to input English.

For setting up keyboard shortcuts in dwm, see my page on it, which has also has links to more involved tutorials. In short, one creates their own config.h, then installs by doing a cd /usr/ports/x11-wm/dwm and using the path to said custom config.h. For example, if I put my custom config.h in /home/scott, I would use
make DWM_CONF=/home/scott/config.h install clean

With portmaster, it's
portmaster -m "DWM_CONFIG=/home/scottro/config.h" x11-wm/dwm
		

In that custom config.h I have two lines in their respective places The first line defines the command.
static const char *imswitchcmd[] = {"imswitch.sh", NULL };

The second line will be in the keyboard bindings. In this case, I chose to use my modkey for dwm, which I've defined elsewhere to be mod4, and y, in part because it's easy to reach while typing and hadn't been used for anything else. So, the other line to reach the script is
{ MODKEY,		XK_y, spawn,     {.v = imswitchcmd } },

(If this isn't clear, it's suggested that the reader check the dwm link given above.)

To sum up, if the tint2 method isn't working for you, create the imswitch.sh script and set up a keyboard shortcut for it, then, using that keyboard shortcut, you should be able to easily switch between English and Japanese. If, for some reason, you can't set up a keyboard shortcut, then set up one for dmenu, because if you can open that, it will use English rather than Japanese, for input, so even you're temporarily unable to get English input, you can run your imswitch.sh from demenu, which will bring you back to English.

As mentioned, I needed this with multiple monitors. Even so, I had to initiate the im switching by clicking the icon on the taskbar--tint2 in openbox, and trayer in dwm. (In dwm, tint2, when used with multiple monitors, doesn't show an icon for ibus.)

It's a kludge, but once I've clicked the icon once and changed from mozc's direct input to hiragana, it works pretty smoothly. In openbox, I leave tint2 open anyway, in dwm, I can close trayer once I've gotten started.

These were the only two that I spent time testing. In fluxbox and spectrwm, there was an icon on the taskbar (with spectrwm, I used tint2) but I could only manipulate it with mouseclicks. Anyway, with multiple monitors, I found it necessary to use byuu's script.

In summary, I think it's far easier to get it working with fcitx5, especially with multiple monitors, where, unlike ibus, it had no trouble.

TOC

OpenBSD

(Last update February, 2024)

One installs with pkg_add fcitx-anthy. This installs fcitx5. As with other systems, one has to add some environment variables--I use $HOME/.xinitrc.
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx
export LC_ALL=en_US.UTF-8
exec openbox-session

That one is if using openbox as the window manager.

At one point OpenBSD only used the xenodm display manager so I couldn't easily drop out of X, edit .config/fcitx5/profile and restart X. Instead, I edited the profile, openbox, my usual window manager and logging in again. I got different results with different VirtualBox installs. In one case, that worked, and I could then input Japanese, in another case, I had to reboot before the changes showed up in profile.

If using xenodm, you may also need to add the XMODIDFIERS=@im-fcitx, etc., to .xsession which is preferred to .xinitc with OpenBSD, when using xenodm.

You can't run fcitx -d, you have to run fcitx5 -d. The configuration file is in $HOME/.config/fcitx5/profile. I edit it to read
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=anthy

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=anthy
# Layout
Layout=

[GroupOrder]
0=Default

If you prefer the GUI tool, you can install fcitx-configtool-qt-5. Once installed, call it with fcitx5-configtool and it opens up the typical fcitx-config dialog. Type anthy in the search box, and it will come up, click the arrow that points to the left, and it will be added to input methods.

7.4 doesn't require xenodm, you can use an .xinitrc file with startx.

One final note, OpenBSD's vi won't work with Japanese. Install nvi, which has no problem. When you install nvi, it gives you a choice of nvi or nvi-iconv, choose nvi-iconv (the other doesn't work right.) So, if you need to edit a text file and include Japanese, open it with nvi, not vi.

TOC

DragonFlyBSD-5.x

(Last update February, 2018)

DragonFly has fcitx-anthy available in packages and ports. One can install from package. We'll need a font, I use sazanami.
pkg install ja-fcitx-anthy ja-font-sazanami

I add the following to ~/.xinitrc, above the line calling the window manager. It can also go in whatever profile file you use, depending upon your shell.
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export LC_CTYPE=en_US.UTF-8

You will need to have dbus installed and running, so add dbus_enable="YES" to /etc/rc.conf and start it with service dbus start

Startx, start fcitx with fcitx -d. Kill X and you should now have a ~/.config/fcitx directory with a profile file. Edit profile and change anthy:False to anthy:True. Startx again, start fcitx and you should be able to input Japanese.

TOC

Using Putty from Windows

Much of this was taken from this page from umiacs.umd.edu.

If you are using Putty to open an ssh session, you can still view Japanese encodings. On the Windows machine, you will have to install Asian Language Support. (Control Panel, Regional Settings or Regional and Language Settings.) You will probably need the Windows installation CD for this. You should also choose the option to Install files for complex script and right to left languages. (The link given above has several screenshots.). Windows will suggest you reboot after installation. Do so.

Open your putty session, right click on the title bar, and choose Change Settings from from the menu.
Go to Window, Appearance. Click the Change button in the Font settings section.
Choose MS Gothic or MS Mincho and Japanese as the script.
Go to the Translation section. In the dropdown box at top, choose UTF-8. Also check the box that says Treat ambiguous CJK characters as wide.

Once this is done, you should be able to view Japanese text in a putty ssh session from a Windows machine.

TOC

Romaji

While only indirectly related, there are times when when one wishes to use special characters when typing romaji. When writing for people studying Japanese, my own tendency is to imitate hiragana, and write, for example, juudou for the martial art. However, for people with no knowledge of the language, this can be somewhat confusing. Most systems that have locales will also have a Compose file for that locale. For example, in FreeBSD, there is a file /usr/local/lib/X11/locale/en_US.UTF-8/Compose. It will probably be elsewhere on a Linux system. That file will have several entries for special characters. Mine has things like
<Multi_key> <underscore> <a>  : "ā"   U0101 # LATIN SMALL
LETTER A WITH MACRON

(If that didn't look like a small letter a with a line over it, then your browser is probably using a different encoding. Go to View=>Encodings and choose UTF-8 and you should see (among other things) a lower case "a" with a line over it.)

This means that if I use the Multi or Compose key, then hit underscore, then a, I will get an a with a line over it. The problem is setting the compose key.

This can be done globally (for all users) by making an entry in /etc/X11/xorg.conf. For example, to use the right Windows key one could add
   Option "XkbOptions"  "compose:rwin"

(Finding the right name can be tricky as it varies on different systems. In FreeBSD, one can find the name in /usr/local/share/X11/xkb/keycodes/xfree86. Usually, you're looking for xkb/keycodes/xfree86.). Another way is to use the xev program, find the numeric code and add it to xmodmap. For example, if I want to use the menu key (usually to the right of the right hand Windows key) I run the xev program from an xterm which opens up a little box. (The xev program is usually installed by default, if not, it's readily available for almost all systems. In FreeBSD it's in /usr/ports/x11/xev.)

In the box, hit a key. In the terminal you used to call xev you'll see various things including (if we hit the right Windows key) keycode 116. Now, we create (if it doesn't exist) a $HOME/.xmodmaprc file. In it we add
keycode 117 = Multi_key

Next type
xmodmap ~/.xmodmaprc

If you now hit the right hand Windows key, then type _a, you'll see ā. So, I can use this to write, for example, jūdō.

TOC

fcitx-fbterm

Using framebuffer, one can now input Japanese in console. I'll add to this as I try it in different systems. To date, I've tried in Fedora, Lubuntu, and Mint and the process was fairly simple.

The fcitx folks have a page on it. In all cases, I already have fcitx working with either anthy or mozc in X. In Fedora install fcitx-fbterm with dnf install fcitx-fbterm. Make sure you have fbterm installed. When I tried it, it wasn't pulled in as a dependency, so I also had to run dnf install fbterm.

In Lubuntu it's apt-get install fcitx-frontend-fbterm. In Mint, it was apparently already installed when I'd installed fcitx.

After that, the procedure is fairly similar. To give an ordinary user access to fbterm, first run
sudo setcap 'cap_sys_tty_config+ep' /usr/bin/fbterm

(In Fedora you can also use /bin/fbterm--both point to the same place)
Add your account to the video group. If your username is john then
usermod -G video -a john

Log out and log back in so the group change can take effect.

If you're already in X and fcitx is already running, you can go to console with ctl+alt+F1 in Lubuntu and Mint, (F2 in Fedora) and type
fcitx-fbterm-helper

This will start fbterm and use the already running instance of fcitx. In the fbterm, you can hit ctl+space and enter Japanese as you would with fcitx in X. To change back to English (or your language) hit ctl+c again. This actually produces a strange character on the screen but if you hit return, you'll get a message that the command wasn't found and what you type afterwards will be in normal English letters.

If you are just in console without X, then you can run
fcitx-fbterm-helper -l

That's a lower case L as in launch. That will launch fcitx and put you into framebuffer terminal.

Once you've done this, you can ssh into another machine and, on the remote machine, also use Japanese in the ssh session. Results may vary--for example I wasn't able to input Japanese on a remote FreeBSD-11-CURRENT machine, but it generally works. (It also works if the local machine is running fcitx-mozc or anthy in an X session, using urxvt or other UTF-8 capable terminal to ssh to a remote machine.)

TOC

Wayland

RedHat is supposedly dropping X for Wayland in RHEL10. If you use Fedora's default of Gnome workstation, you probably won't see a difference. As I prefer dwm and openbox, I wondered how it might affect my workflow if X was gone, so I tried Wayland on Fedora and FreeBSD.

The main difference, for me, at least, is that I usually load my environment variables in .xinit. Both Fedora and FreeBSD have labwc, which is more or less a dropin for openbox. I have more information on my wayland page.

The labwc window manager has (though you'll have to create it), a place for environment variables in $HOME/.config/labwc. Create a file $HOME/.config/labwc/environment, and put your usual variables in there. Mine reads
XMODIFIERS=@im=fcitx
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
LC_CTYPE=en_US.UTF-8

As usual, if using the kitty terminal emulator also add a line of export GLFW_IM_MODULE=ibus to that file.

This allows me to input Japanese in all the applications I've tried, which at this point are just firefox urxvt, and alacritty. With dwl, I have not gotten Japanese to work well.

With dwl, I can only get Japanese input by using export XMODIFIERS=@im=fcitx and using a urxvt terminal. It doesn't work in alacritty or kitty. And, exporting the other usual things (all mentioned above in the part about labwc) makes no difference. It still won't work in firefox or various terminals. Only in urxvt, and I only need to export the XMODIFIERS variable.

It will work in libreoffice, but ONLY if I call libreoffice from the terminal where I set the variables. In that case, I have to call the QT_IM_MODULE as well. I can export the QT_IM and XMODIFIERS from alacritty as well, and, if I call urxvt or libreoffice from the terminal where I exported the variables, Japanese input will work. I haven't figured out the reasons yet, but to simplify:
If, in alacritty or urxvt I run export XMODIFIERS and export QT_IM_MODULE, I can then, from that terminal, open libreoffice or a urxvt terminal and input Japanese. This doesn't work for firefox though it does for chrome. I may investigate more, but practically speaking, if I'm using Wayland, which I seldom do, and have to input Japanese, which I now do infrequently, I'll probably use labwc.

As mentioned in the FreeBSD section, on some FreeBSD installs, I found that qt apps wouldn't work with Japanese. I had the same experience with Wayland. I would have to use dbus-launch labwc in order to use QT apps with Japanese in Wayland.

I have had limited success with running a little script with dwl--on occasion. I just declare the same environment variables that I use in labwc. So the script will look like
#!/bin/sh
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=xim
export QT_IM_MODULE=fcitx
export LC_ALL=en_US.UTF-8
fcitx5 -d -r
$1 &

I run the script after I've opened a dwl session. I usually only want either a web browser or terminal open, so I might run it as jinput.sh firefox, or jinput.sh alacritty. That's in FreeBSD. In Fedora, as of 11/2024, there is no rpm. I had to build the tarball, from dwl's site. The git version seemed to need a newer version of wlroots so I used the tarball for 0.7. Also, see the page's information about Xwayland. One has to uncomment a couple of lines in config.mk to get Xwayland support, as well as be sure you have libxcb and wlroots-devel. (The page also says you need libxcb-wm, but Fedora didn't have that, and I didn't use it, but Xwayland support worked). The main reason for Xwayland support, for me, was to get urxvt to work, otherwise, it wouldn't open in dwl. so I could only use either xfce4-terminal or gnome-terminal working with Japanese, unless I included Xwayland support.

The script usually doesn't seem to actually export the variables. Usually, I have to specify the variables in a terminal, then call xfce4-terminal or gnome-terminal from the terminal in which I declared the variables. That is, a keyboard shortcut, or starting it from wmenu, won't have the variables in it. (I can, say, open an xfce4-terminal, declare the variables there, and then use that same terminal to input Japanese, but if I want to use Japanese in libreoffice, say, I'll have to call the libre office session from that terminal.

The other possibility is to call the environment variables in ~/.bash_profile. (Not .bashrc, because things like libreoffice, for example, might not involve an interactive shell.) Or, if you use zsh, one can put the variables in ~/.zshenv. Regardless, dwl has various shortcomings with Japanese inputr, at least with fcitx5, the only method I have tried.

I've not made much use of Fedora's default workstation, which uses ibus and Gnome, but when I did, Japanese worked as it would in X. If one just uses Fedora's defaults, I expect they'll have no problem. However, I always choose a minimal install and install window managers afterwards.

Basically, if I need Japanese, in Wayland, I've been relying on labwc. Again, this is on FreeBSD, in Fedora, I'd use xfce4-terminal. So, if Wayland does become the only alternative, I'll be in good shape, though I don't expect that to be a problem for years.