How do I toggle input modes with Mozc?

I'm using Gnome with an international keyboard and I configured it to use fcitx IBus. I also installed Google_Japanese_Input in Windows, where it behaves as expected:

  • Alt + Shift switch between languages (IMEs)
  • Ctrl + Caps Lock switch to Hiragana
  • Alt + Caps Lock if in alphanumeric mode change to Hiragana, then switch to Katakana
  • Shift + Caps Lock switch between full-width Hiragana ↔ full-width alphanumeric (romaji)
  • Alt + ` (Grave Accent) switch between kana ↔ half-width alphanumeric (romaji)
  • Alt + ~ (Tilde) toggle kana/direct input

These keyboard shortcuts do not work in Gnome. I have to select the modes manually from the menu.

I understand that Alt + ` interferes with the application switcher shortcut but I doubt that I'm the only user using Gnome and trying to get it to work like an average user would do on any other platform. If there was a serious issue with the existing keyboard mappings there should at least be some kind of best practice or recommendation how to create a useful mapping instead of everyone starting from scratch rolling her/his own? I'm not convinced by existing answers (1, 2) and I could not find any good resources how a Linux user is supposed to configure and use Mozc (1, 2) efficiently.

So my question I'd like to have a complete answer here is:

  • What is the recommended Japanese input method for Ubuntu 18.04 and later? (I assume it is Mozc.)
    • Which packages need to be installed?
    • How is the input method configured in Gnome? (A Windows user just downloads and installs the Google software for comparison. It just works.)
  • How to set up the input method itself?
    • How to set up switching of input modes?
    • Are there any conflicts with keyboard shortcuts? How to resolve?
    • Are there any conflicts with other IMEs or software components (like UIM, IBus)? How to resolve?
  • Is there any useful documentation how to use the IME? (Or typical Japanese IME in general.)
    • Would be useful to verify that it is working correctly.
    • Understanding how the software is supposed to be used by average users. There seem to be a lot of shortcuts and additional functionality to tweak but also to make your experience worse than instead of going with the default where possible.

Update:

After a few reboots I find that fcitx does not work when I set the mode to Hiragana and type in Gedit. Trying to reconstruct the behavior I must have been using Ibus at the time. When I try Ibus it works.

I had reset my keyboard shortcuts on this computer when I moved from Unity to Gnome, thus running the defaults except for the take screenshot key which I have disabled. I previously had setup custom compose keys (1, 2), but I disabled export GTK_IM_MODULE="uim" and export QT_IM_MODULE="uim" in my .profile when moving to Gnome with Wayland due to a bug. Sequences like Compose+.+. and Compose++ do work though.

When running fcitx I get the following output:

$ printenv | grep -i im_module 
CLUTTER_IM_MODULE=xim
QT4_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
GTK_IM_MODULE=fcitx

When running ibus I get the following output:

$ printenv | grep -i im_module 
CLUTTER_IM_MODULE=xim
QT4_IM_MODULE=xim
QT_IM_MODULE=ibus
GTK_IM_MODULE=ibus

Update 2:

Okay as far as I understand fcitx does not integrate well with Gnome at the moment. I try to go with IBus since I don't want fcitx to interfere with keyboards and configure keyboards in Gnome and fcitx (across several desktops and laptops). While I have no problems using Ctrl + Caps Lock and Alt + Caps Lock in Windows, Mozc on Linux has the Japanese keys in it's mapping and the Alt and Eisu keys don't seem to be supported. There is an entry on the Arch Wiki regarding X tools (I'm not sure about Wayland) and some Japanese users seem to have found their ways, but this is way too much for me right now.

Update 3:

While users on Arch use a custom AUR package I found a simple quilt patch for easy applying and recompiling to the latest version. I hope this can be included in Ubuntu one way or another while the Linux version has no documented way of making the quoted shortcuts work like on other OSes. With this annoyance gone I consider my issue almost solved. Lets see what happens with the bug report or upstream in the mean time.


Solution 1:

What is the recommended Japanese input method for Ubuntu 18.04 and later? (I assume it is Mozc.)

The IMF is IBUS (comes installed from Ubuntu's ISO). The IME is MOZC (most commented here in Askubuntu) followed by Anthy.

But it is so subjective. Install all of them! And try each one!

Which packages need to be installed?

On Ubuntu 18.04, you need to install 3 kinds of packages:

Language

You need to install the japanese language (to get the base packages). Following the instructions in Writing Japanese with Ubuntu 18.04 LTS Bionic Beaver and Japanese Input:

  1. In system settings, select Region & Language.
  2. Click Manage Installed Languages.
  3. In the Language Support window, click on Install / Remove Languages....
  4. In the Installed Languages window, check Japanese, click Apply.
  5. Log out of your Ubuntu profile to get effect.

IMFs packages

You can install one (or both) IMFs. Ubuntu comes with ibus installed. To install, type:

  • ibus: sudo apt install ibus
  • fcitx: sudo apt install fcitx.

IMEs packages

You need to install japanese IME(s) for each installed IMF. For example, Ubuntu comes with ibus IMF. So you can install one (or more) of these japanese IMEs:

  • mozc: sudo apt install ibus-mozc
  • Anthy: sudo apt install ibus-anthy.
  • KKC: sudo apt install ibus-kkc.
  • SKK: sudo apt install ibus-skk.

And if you installed fctix IMF, you will need to install at least one of its specific japanese IMEs:

  • mozc: sudo apt install fcitx-mozc
  • Anthy: sudo apt install fcitx-anthy.
  • KKC: sudo apt install fcitx-kkc.
  • SKK: sudo apt install fcitx-skk.

How is the input method configured in Gnome? (A Windows user just downloads and installs the Google software for comparison. It just works.)

First install: japanese language, one IMF, and one japanese IME.

After that, you only need to click on GNOME Status Menu (Gnome's top-right bar) > IBus menu (i.e. keyboard/input language selector) > Select your desired input method.

Gnome and japanese input methods

Or use the shortcut: hold Super and press Space.

enter image description here

How to set up the input method itself?

Each IMF and each IME have their configurations, menus, windows and so on.

How to set up switching of input modes?

To switch between japanese input modes (e.g. hiragana, katakana etc) is a important requirement. Each IME comes with their own:

  • shortcuts or binding keys to switch japanese modes.
  • plus that, has graphical submenus at GNOME Status Menu to switch between japanese modes and access its configurations.

Are there any conflicts with keyboard shortcuts? How to resolve?

No. Each IME has their keymap editor. So you can edit any conflict, if exists.

Are there any conflicts with other IMEs or software components (like UIM, IBus)? How to resolve?

I don't thing so.

Is there any useful documentation how to use the IME? (Or typical Japanese IME in general)

  • Installation: see Writing Japanese with Ubuntu 18.04 LTS Bionic Beaver and Japanese Input.
  • Questions and answer: https://askubuntu.com/ and https://japanese.stackexchange.com/
  • IME official sites: mozc, Anthy, KKC, SKK.
  • and google/youtube/reddit.

Would be useful to verify that it is working correctly.

Only install all packages, select the IME from GNOME Status Menu and type in any text field.

Understanding how the software is supposed to be used by average users. There seem to be a lot of shortcuts and additional functionality to tweak but also to make your experience worse than instead of going with the default where possible.

After select the installed japanese IME, you will need to know the shortcuts to change the japanese input mode. For example, you can see all ibus-mozc keymap and its romaji-hiragana table.