Japanese Input with Fedora 40, Fcitx5, Wayland

3 min read

Update history

  • First published 2024-6-19 when using Fedora 40.
  • Updated 2024-11-23 when using Fedora 41. Added note about how I configure the 英数 and かな buttons.

I've been trying to get Japanese input working on Fedora with Wayland.

I found that the "default" ibus-anthy input method works for X11 apps but is not as reliable for Wayland apps.

Overall, I get the impression that Fcitx5 is the most future-proof IME at the moment, with better overall compatibility for both X11 and Wayland.

Unfortunately, I have not figured out how to get Google Chrome and VS Code working in Wayland mode with IME support yet. So this is not necessarily the most useful post, but I think it is still good to document my experience for when I inevitably want to try this again in 6 months.

References

Installation

Install Fcitx5 and the Japanese input method:

sudo dnf install fcitx5 fcitx5-autostart fcitx5-anthy fcitx5-configtool

Note that the fcitx5-autostart package is a custom Fedora package that basically just puts a script in your /etc/profile.d/ directory like this:

if [ ! "$XDG_SESSION_TYPE" = "tty" ]   # if this is a gui session (not tty)
then
    # let's use fcitx instead of fcitx5 to make flatpak happy
    # this may break behavior for users who have installed both
    # fcitx and fcitx5, let then change the file on their own
    export INPUT_METHOD=fcitx
    export GTK_IM_MODULE=fcitx
    export QT_IM_MODULE=fcitx
    export XMODIFIERS=@im=fcitx
fi

Enable the Kimpanel extension for Gnome: https://extensions.gnome.org/extension/261/kimpanel/

Configuration

After restarting my computer, I configured my input settings in the Fcitx5 GUI.

As I have a Japanese layout keyboard, I used the "Select system keyboard layout" button in the GUI to set my keyboard, and it seemed to pick that up for both English and Anthy (IME) modes.

My failed experience with Google Chrome

For Chrome and Electron apps, in addition to setting Wayland mode via chrome://flags or via the command line flags:

google-chrome --enable-features=UseOzonePlatform --ozone-platform=wayland

It is said that you can pass either the flag --gtk-version=4 or --enable-wayland-ime to get IME features working as well. However, neither was responsive for me, and --enable-wayland-ime literally caused the browser renderer process to crash. It just doesn't seem worth pursuing further at the moment.

At the same time, X11 mode is working perfectly. So I guess I will just continue to use that for now.

Maybe next year it will work?

Configuring 英数 and かな buttons on a Japanese Mac Keyboard

Screenshot of a Japanese Mac keyboard layout showing the 英数 (Eisu) and かな (Kana) keys used for switching between English and Japanese input modes

I have a Mac laptop running Fedora. In macOS, the 英数 button switches to English mode, and the かな button switches to Japanese mode. Originally I set keybindings in the Japanese IME so the 英数 button switches to Latin input inside the Japanese IME; however, this turns out to be very annoying for coding because some coding shortcuts like Ctrl+/ do not work correctly.

I was about to write a script to fix this when I found an extension called Input method and touchpad shortcuts. With this, I could bind the 英数 button to the English Input Source and かな to the Japanese IME. Much better!

Screenshot of GNOME keyboard shortcuts settings showing the configuration for 英数 (Hangul_Hanja) and かな (Hangul) keys to switch between English and Japanese input methods

I don’t know why but these buttons appear as Hangul_Hanja and Hangul in the UI.