Note: Set Up ibus-rime Chinese Input Method

Published on

Original language: Chinese . AI translations: English , Japanese .


iBus-rime initial setup

By 2023 I had switched to Fcitx.


Autostart iBus and keep it in the background

After installing the Rime input method on Linux, you need iBus support.
But after fiddling with iBus settings, once I closed the window, iBus just exited…

I checked the docs: iBus Initial setup - Archlinux

Append to the end of ~/.bashrc:

Terminal window
# iBus always on
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -drx

The method above worked in a VM, but didn’t work on my laptop.

Still from the docs: create ~/.xprofile and add:

Terminal window
# iBus always on
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -drx

Full install process

Terminal window
# install plum : https://github.com/rime/plum
curl -fsSL https://git.io/rime-install | bash
# install double-pinyin
cd plum
bash rime-install double-pinyin
# install ibus-rime
pacman -S ibus-rime
# modify home/user/.config/ibus/rime/default.yaml, add double-pinyin schema
# create home/user/.xprofile, add following commands
# iBus always on
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -drx
# log out, and log in

2020/03/08 update

Installed again and optimized the steps a bit:

Terminal window
# install plum bash: https://github.com/rime/plum
git clone https://github.com/rime/plum.git
# install double-pinyin
cd plum
bash rime-install double-pinyin
# install ibus-rime
pacman -S ibus-rime
# modify ~/.config/ibus/rime/build/default.yaml
# add double-pinyin to `schema_list`
# create ~/.xprofile, add following
# iBus always on
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -drx
# log out, and log in
# iBus will autostart

Changes:

  • Use git clone to download plum. The original one-liner runs the script directly and installs a bunch of input schemas I don’t need.
  • The path of rime default.yaml changed; contents seem similar. Just edit it.

Pitfalls:

  • It’s best to edit rime default.yaml first, then start iBus and switch to rime input method.
  • Because when rime starts for the first time, it deploys input schemas based on default.yaml (converts .yaml schemas to .bin for faster usage).
  • If you edit the config first, deployment can finish in one go.

    I got stuck on this for 3-4 days…
    I started rime first, then after editing the config I couldn’t find where to redeploy.
    I searched online: “there’s a deploy button”, but I couldn’t find it anywhere; CLI commands didn’t help either.
    In the end I realized:
    Left-click the rime tray icon and you’ll see deploy options… (I always right-clicked, which shows iBus options.)
    I’m too noob.

Issues:

  • One issue: in terminal, rime candidate popup doesn’t appear at the cursor; it jumps around. Kinda tiring…

    2020/03/10 update
    Found it’s not just in terminal; editing Google Docs in browser also has this issue…


2020/04/12 update: start iBus via . .xprofile

Previously I always logged out and back in to load .xprofile.
Today iBus crashed and I didn’t want to log out.
Then I thought: if . .bashrc or source .bashrc can refresh the shell environment, can . .xprofile do the same?
Tried it; it works.


2020/11/28 update

manjaro-kde-20.1.2-201019-linux58 kde desktop crash when using .xprofile
edit ~/.bashrc is ok

Terminal window
# iBus always on
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
ibus-daemon -drx

default.yaml file at /usr/share/rime-data/default.yaml

2021/02/21 update
Now there is no default.yaml under ~/.config/ibus/rime/. Docs online recommend not editing /usr/share/rime-data/default.yaml directly (because upgrades will wipe custom changes).


2021/02/21 update DIY ibus-rime

Recommended approach: add patch files under ~/.config/ibus/rime/.

  • Add double-pinyin schema
    Github - rime/rime-double-pinyin
    Download the schema you need and copy it into ~/.config/ibus/rime/. Mine is double_pinyin_flypy.schema.yaml.
    Then apply a patch:

    Terminal window
    vim ~/.config/ibus/rime/default.custom.yaml
    # add following lines
    patch:
    schema_list:
    - schema: double_pinyin_flypy

    Redeploy and it takes effect.
    This patch overrides the default schema_list. If you need other input methods, add them in the patch too. (Be careful with YAML syntax.)

  • Make candidate menu horizontal
    After an upgrade, the horizontal layout setting in ibus stopped working. The workaround:

    Terminal window
    vim ~/.config/ibus/rime/ibus_rime.custom.yaml
    # add following lines
    patch:
    style:
    horizontal: true

Ref:
RIME | 中州韻輸入法引擎 幫助文檔
Rime 定製指南 - 定製方案選單
Cannot get ibus_rime.yaml to work - unable to set my style/horizontal to true
可能只适合我自己的 RIME 配置 <<< this is great


2021/05/09 update

Install ibus-mozc-ut Japanese Input Method

On Manjaro (iBus framework), to install a Japanese input method, it seems the AUR package is ibus-mozc-ut.
It took 20 minutes to build. After installation I couldn’t make it show up, wasted half an hour.
Turns out it was because I didn’t log out & log in… (sorry. I should follow tutorials and not skip the log out step
After logging in again, Japanese - Mozc shows up. Then configure Romaji Input Method, Hiragana, etc.
More IME tricks still to learn~


2022/02/20 update

Found another config with more env vars

Terminal window
# iBus always on
export INPUT_METHOD="ibus"
export XMODIFIERS="@im=ibus"
export GTK_IM_MODULE="ibus"
export QT_IM_MODULE="ibus"
export QT4_IM_MODULE="ibus"
ibus-daemon -drxR --panel=/usr/lib/kimpanel-ibus-panel

2023/05/18 update

Switching to Fcitx

After a big distro upgrade, ibus-rime broke. It would deploy for a bit then exit, taking ibus down with it.
Couldn’t fix it, so I switched to Fcitx.

Chinese input uses fcitx5-rime.
(Also installed fcitx5-mozc-ut so I can type Japanese too. The dictionary is pretty complete and suggests common words. Nice.)

For Rime config I use 雾凇拼音

If telegram-desktop can’t use Chinese input, add these env vars to ~/.xprofile:

Terminal window
export XMODIFIERS="@im=fcitx5"
export XMODIFIER="@im=fcitx5"
export GTK_IM_MODULE=fcitx5
export QT_IM_MODULE=fcitx5
export DefaultIMModule=fcitx5
fcitx5 &

Ref:
Archlinux - Fcitx5
Archlinux - Rime
Cannot type Chinese in some applications

Comments