Fcitx5 rime on pinephone postmarketOS

Published: Thursday, April 7, 2022

Tags: linux pinephone

One of the requirement for me to daily drive a Linux phone is the foreign language input support (Chinese, Japanese, etc). While it is easy to setup ibus or fcitx5 on a more popular Linux distro such as Arch and Debian (Arch ARM and Mobian for pinephone), doing in on postmarketOS (Alpine Linux) is not so straightforward. Mostly due to the issues in the official/community packages. We have a few options:

  1. third party (wlpinyin): this is what I ended up using for Chinese
  2. fcitx5 (fcitx5-rime): more language support, works for Qt applications
  3. ibus (ibus-rime): did not work

Option 1. wlpinyin

This is an experimental wayland IME. I like it becase it can display selector menu in terminal/vim. It needs librime as the backend. Installation from source is easy:

git clone https://github.com/xhebox/wlpinyin.git
cd wlpinyin
meson build
ninja -C build

The only problem is that left Ctrl key is set as the default switcher key between normal and pinyin input, But the on-screen keyboard (wvkbd) sends Ctrl as a modifier instead of a key stroke. I changed the default switcher key to 'End' key by editing config.c: replacing XKB_KEY_Control_L with XKB_KEY_End.

I also added a userscript in sxmo to start/stop the input engine, located at .config/sxmo/userscripts/


isopen() {
    if [ -z "$WLIME" ]; then
        exit 0
    pidof "$WLIME" > /dev/null

open() {
    if [ -n "$WLIME" ]; then
        eval "$WLIME" &

close() {
    if [ -n "$WLIME" ]; then
        pkill "$WLIME"

if [ "$1" = "open" ]; then
elif [ "$1" = "close" ]; then
    if isopen; then

The librime package found in Alpine edge testing repo did not work for me. I had to build from source. Besides Chinese, there are also Korean and Japanese IME found on this page.

Option 2. fcitx5

For some reason the fcitx5 (5.0.15-r0) from Alpine edge testing repo did not for me. There were missing files after installation. The only option is to build from source. Luckily, the fcitx5 github repo has pretty complete guide and instructions.

1. Install fcitx5 from source

This wiki provides a list of dependencies for compiling fcitx5. Most of these packages can be found in Alpine repo, and installed by sudo apk add package-dev. It is a little tricky to find the correct package name, but Duckduckgo can help with that. It takes about 1-2 hours on the pinephone to build.

2. Install fcitx5-qt and fcitx5-gtk

Similarly, clone the git hub repos fcitx5-qt and fcitx5-gtk, run cmake with the correct options, especially for fcitx5-qt, use -DENABLE_QT4=Off, for fcitx5-gtk, use -DENABLE_GTK4_IM_MODULE=Off, since there isn't a gtk4 package in Alpine repo yet and I do not want to spend hours building gtk4 from source.

3. Install fcitx5-rime

From github source.

4. Install librime

Again, the package found in Alpine edge testing repo does not work. To build from source,

git clone https://github.com/rime/librime.git
cd librime
sudo make install

(Do not cmake . otherwise it will mess up the plugins) There are also problems with the Alpine repo packages yaml-cpp. It threw out and error "undefined reference to 'std::__throw_bad_array_new_length()". Had to install that from source too.

5. Install plum for different input schemas

Need to set rime_dir for install

rime_dir="$HOME/.config/fcitx5/rime" bash rime-install

6. Configure fcitx5

I'm using sxmo sway, therefore need to add to sway configuration ~/.config/sway/config to start fcitx5 on every reboot

exec_always fcitx5 -d --replace

Also, apparently the fcitx5-configtool GUI doesn't work in sxmo. Need to manually change the fcitx5 config by editing ~/.config/fcitx5/profile

# DefaultIM settings
# Rime is for Chinese (supported by `fcitx5-rime`)
# DefaultIM=rime

# Group Name
# Layout
Default Layout=us
# Default Input Method

# Name
# Layout

# Name
# Layout


Also edit environment variables in ~/.pam_environment to have


or edit ~/.profile

# export fcitx5 environment variables
export GTK_IM_MODULE=fcitx5
export QT_IM_MODULE=fcitx5
export XMODIFIERS="@im=fcitx5"

Reboot and we get an unhappy face on the status bar.

sxmo unhappy face on status bar

Hit Ctrl+Space and it starts to work. Example in foot terminal:

sxmo rime working in terminal

The only problem is that no selector UI is renedered. But in a Qt5 application such as qutebrower, it works perfectly:

sxmo rime working in terminal

Also, don't forget to download fonts. According to official alpine wiki, Chinese fonts are not included in the repo. We can just download from Google noto fonts and copy the files to /usr/share/fonts/noto/

7. Other issues and tweaks

Key binding conflict with default sway config

In addition, due to the way Shift key works in the virtual on-screen keyboard, I tried to avoid using Shift key. To change the enumerate group key (for more than one group), edit ~/.config/fcitx5/config





No selector UI in GTK application?

For example, in Firefox, the UI doesn't show up.

Resources [1], [2]