Web Analytics

Technically Impossible

Lets look at the weak link in your statement. Anything "Technically Impossible" basically means we haven't figured out how yet.

Input environment for Asian languages with Fcitx5 via Flatpak: Works on Any Distribution

Recently, I purchased a new PC*1 and started setting it up. One of the things I wanted to try this time was switching my Japanese input environment from IBus*2 to Fcitx 5*3.

I had heard that Fcitx 5 could be installed from Flatpak regardless of the Linux distribution, and this turned out to be true. This is great news, especially for users of less common distributions like Clear Linux*4, as it eliminates the need to worry about package manager dependencies or building from source.

In this post, I will guide you through the installation process, including Mozc, and also discuss some related aspects concerning GNOME Wayland.

While this post focuses on Mozc for Japanese input, the approach is also applicable to other Asian languages. Fcitx add-ons are available for Chinese, Hangul, and more, so readers can adapt these instructions for their preferred language. For me, Mozc is the primary focus.

I am using Clear Linux for this demonstration, but as mentioned earlier, since we are using Flatpak, the installation procedure should be identical across different distributions.

Installing Fcitx 5 and Mozc

flathub.org

Fcitx 5 can be installed from Flathub via a web browser, or via a Flatpak GUI application if you have one installed.

Mozc is provided as an add-on for Fcitx 5, so after installing Fcitx 5, install it via a web browser or GUI application.

Alternatively, Fcitx 5 and Mozc can be installed from the command line. In that case, execute the following command.

flatpak install org.fcitx.Fcitx5
flatpak install org.fcitx.Fcitx5.Addon.Mozc

After installation, as shown in the following screen, a message recommending the installation of the Gnome extension is displayed.

Installing the Gnome extension "Input Method Panel"

The Gnome extension recommended by the message is the Input Method Panel. It displays an IME icon on the Gnome menu bar.
Like Fcitx 5, it can be installed from a web browser, or you can download the source code from GitHub, build, and install it.

extensions.gnome.org
github.com

Building and installation is also easy, just execute install.sh in the downloaded source code folder.
If you download gnome-shell-extension-kimpanel to the /tmp directory, the command will be as follows.

cd /tmp/gnome-shell-extension-kimpanel
chmod 777 install.sh
./install.sh

After installation, log off and log back in. Then launch "Extensions", the Gnome extension manager. Enable "Input Method Panel" there.

Then, when you start Fcitx 5, the Fcitx 5 icon will be displayed in the menu bar.

Fcitx 5 settings

From the Fcitx 5 icon displayed in the menu bar, follow the menu and select "Settings".

Move "Keyboard - English (US)" displayed in the left pane of the "Input Method" tab to the right pane.
If you enter "Mozc" under "Available Input Method" in the right pane, you can narrow down the target items. Once you have narrowed down "Mozc", move it to the right pane.
After completing these steps, click the 'Apply' button and close the Fcitx Configuration window.

If you select "Reload Configuration" from the menu from the Fcitx 5 icon displayed in the menu bar again, the icon will change to the Mozc icon.

In this state, Mozc is working and Japanese input is also functioning. If you feel the need to reconfigure while test typing, follow the menu from the Mozc icon and select "Mozc Settings".

Automatic startup settings

In this state, you need to start Fcitx 5 every time you start your PC. Until it starts, you cannot input Japanese with Mozc. Many users, including myself, want to start Fcitx 5 automatically.

Assuming GNOME Wayland, you need to handle the following two things.

  • Setting environment variables
  • Setting automatic startup

Environment variables are saved in the following path.

~/.config/environment.d/

It is good to divide the environment variables into files in units that are easy for each user to classify. For example, in the case of Fcitx 5, prepare a file that records only the environment variables dedicated to it, and name it fcitx5.conf.
The environment variables to be defined are as follows.

im=fcitx5
GTK\_IM\_MODULE=$im
QT\_IM\_MODULE=$im
XMODIFIERS=@im=$im
INPUT\_METHOD=$im
SDL\_IM\_MODULE=$im

Launch "Tweaks", the Gnome setting manager, and add Fcitx 5 at the tab "Startup Applications". Or save a desktop file to the following path.

~/.config/autostart/

This is similar to how you would add a program to the startup folder in Windows. In other words, you just need to copy the Fcitx 5 desktop file to the relevant folder.
To do this, execute the following command.

cp \~/.local/share/flatpak/exports/share/applications/org.fcitx.Fcitx5.desktop \~/.config/autostart

This allows you to maintain a Japanese input-enabled state automatically even after restarting your PC.

For more detailed information on Wayland environment variable definitions and automatic startup settings, please refer to the following post.

impsbl.hatenablog.jp