Chinese Input Method with fcitx

Just went through the setup, which required a little head-scratching, and wanted to share some "getting-started" instructions while they're fresh in my mind. The process is actually pretty easy and the tool works great. The script below is what I'm using to set this up on FreeBSD with Lumina and XDM.

I don't know offhand how to integrate the XMODIFIERS and *IM* variables in other display managers such as gdm, kdm, sddm,
or slim. Everything else in the script should be desktop and display manager independent, though.

Code:
#!/bin/sh -e

# Install a decent set of Chinese fonts
pkg install zh-CJKUnifonts zh-font-std zh-opendesktop-fonts zh-CNS11643-font \
    zh-kcfonts

# Install fcitx, some associated tools, and a couple input methods
# libpinyin and sunpinyin are input methods that seem to work well
# qtconfig can be used to set QT4_IM_MODULE
pkg install -y fcitx-qt5 zh-fcitx-sunpinyin zh-fcitx-configtool \
    zh-fcitx-libpinyin zh-fcitx-cloudpinyin qt4-qtconfig

cat << EOM

Set GTK_IM_MODULE, etc. in /usr/local/etc/X11/xdm/Xsession, ~/.xsession,
and/or other X startup scripts as described in the fcitx pkg-message.

Portable Bourne-shell example:

    XMODIFIERS='@im=fcitx'
    GTK_IM_MODULE=fcitx
    GTK3_IM_MODULE=fcitx
    QT4_IM_MODULE=fcitx # Or use qtconfig to change
    export XMODIFIERS GTK_IM_MODULE GTK3_IM_MODULE QT4_IM_MODULE

If you want fcitx running all the time, add fcitx to your desktop auto-start
using your desktop config tool or manually, e.g.

    ln -s /usr/local/share/applications/fcitx.desktop ~/.config/autostart

Log out, restart X11, and log back in.

Run fcitx if you did not add it to your autostart.

Right-click fcitx in the tray, select "Configure".

Uncheck "Only Show Current Language".

Add languages from "Available" to "Current".  The LibPinyin and Sunpinyin
options seem to work well.

Right-click fcitx in the tray, select "Restart".

Run some application (e.g. firefox) in which you want to use the Chinese input
method.  The fcitx IM selector applies only to the active window.

Right-click fcitx in the tray, select "Input Method" and choose your IM.

EOM
 
Back
Top