How to run Fcitx5 and Rime on Ubuntu 20.04

/ 教程, english

In the recent few days, I tried to install and run Fcitx5 and Rime on my Ubuntu 20.04, and I’ll be summing it up in this post.

Ibus versus Fcitx

Ibus and Fcitx are both input methods to be used to input diverse language characters. If you’re struggling to decide which one to choose, I would suggest using the latter one for below points:

  1. Check out the GitHub commits of them, you would notice Fcitx is much more actively developing now.
  2. From my using experience, Fcitx certainly ships more features and works more smoothly as well.

What is Rime and why

Rime is also an input method, but it especially resides in Fcitx and Ibus with aiming to provide a highly flexible way to input characters:

  1. By using it you can mix lots of input methods together and define your own typical input method scheme and dictionaries.
  2. By using it you can customize and use an Emacs style shortcut(e.g. Ctrl/Alt + N/P/B/F/V) to select and navigate between candidate characters from your typing, and this feature is supported by Rime out of the box.

I initially use Rime later after I started to design my Ming-Lang. Since in my Ming Language, I need to design new Chinese characters and give them unicode codes to input them into the computer. If you’re interested, check out my rime_custom repo for more.

What is the hard part

It’s not easy to run Fcitx5 and Rime on Ubuntu 20.04 due to library dependency. A much more easily achieved way could be updating Ubuntu to a newer version, but that is not on my wish list because of the incompatibility of some system plugins I’m using now.

I also tried to install the fcitx5 packages from the result of aptitude search fictx5, but there are two fatal flaws make me give it up:

  1. No viable GUI configure tool here, which means inconvenient configuring regardless of successfully installing Fcitx5.
  2. No Rime package here, which means impossible of using Rime irrespective of successfully installing Fcitx5.

How to install Fcitx5 with using Flatpak

You may have ever heard of Docker, while Flatpak is the same kind of thing in terms of using the OS-levle virtualization.

So in simple words, by providing a sandbox environment for an application and its dependencies libraries, Flatpak is capable and thus can be used to install an application with getting rid of library dependencies of current system.

Then there comes a way to install fcitx5 and fcitx5-rime with Flatpak:

  1. Follow the official guide page and install flatpak for Ubuntu.
  2. Use command flatpak install org.fcitx.Fcitx5 org.fcitx.Fcitx5.Addon.Rime --system to install fcitx5 and fcitx5-rime.

How to debug Rime

Since we installed Rime with Flatpak and the Rime application accordingly exists in a standalone namespace provided by Flatpak, we have to use the flatpak command to access it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  ~ flatpak ps
Instance   PID  Application      Runtime
1453884543 1670 org.fcitx.Fcitx5 org.kde.Platform
➜  ~
➜  ~ flatpak enter 1453884543 bash
bash-5.1$
bash-5.1$
bash-5.1$ tail -f /tmp/rime.fcitx-rime.*
==> /tmp/rime.fcitx-rime.INFO <==
I1109 15:09:19.253913     2 config_data.cc:223] traverse: simplifier/option_name
I1109 15:09:19.253917     2 config_component.cc:82] read: simplifier/opencc_config
I1109 15:09:19.253921     2 config_data.cc:223] traverse: simplifier/opencc_config
I1109 15:09:19.253926     2 config_component.cc:104] read: simplifier/excluded_types
I1109 15:09:19.253929     2 config_data.cc:223] traverse: simplifier/excluded_types
I1109 15:09:19.253939     2 config_component.cc:104] read: switches
I1109 15:09:19.253943     2 config_data.cc:223] traverse: switches
I1109 15:09:19.253952     2 engine.cc:123] updated option: ascii_mode
I1109 15:09:19.253962     2 engine.cc:123] updated option: simplification
I1109 15:23:56.695946     2 engine.cc:92] engine disposed.
  1. Use flatpak ps to list out all the running applications.
  2. From the result of step 1 we have the instance id of org.fcitx.Fcitx5, which is 519459212. Then we use flatpak enter 519459212 bash to start up a bash console within the namespace of Fcitx5.
  3. At last we use tail -f /tmp/rime.fcitx-rime.* to check out all the logs of Rime.

Troubleshooting Fcitx5

After I installed fcitx5 with flatpak, there is a time that I cannot switch input method schemes of Rime within Fcitx5 after booting the Ubuntu system, until I notice that there is a fcitx-diagnose command, the output message of running which shows that some system environment variables are missing in my system. Then I followed it and put the below code to ~/.xprofile:

1
2
3
export XMODIFIERS=@im=fcitx
export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx

Additionally, I guess there are some dependency between fcitx5 and fcitx4, we should use sudo aptitude install fcitx to install fcitx4 as well.

And I also notice that if I chose fcitx as the default input method on 区域与语言 panel of system GUI settings, I don’t have to set up the variables to ~/.xprofile, but this does not help since it will start up the aptitude-installed Fcitx4 first and also there is not a flatpak-installed fcitx5 to be chosen either.