1. Remove "i18h.h" for iBus
We can remove the file "/etc/profile.d/i18n.h" so that the system variable "LANG" will be handled by the file "/etc/locale.conf" only. The advantage is we can use the systemd command "localectl" to configure the system locale. (The command "localectl will NOT handle the file "i18h.h" so sometimes you will find that the system locale is incorrect even you have used the command "localectl" to set your system locale setting.)
2. Setup system variables for ibus
Create the following file:
cat > /etc/profile.d/ibus.sh << EOF
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
EOF
3. Setup auto start for iBus
Create the following file:
cat > /etc/xdg/autostart/ibus-daemon.desktop << EOF
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.5.18
Name=ibus-daemon
Comment=iBus Daemon
Exec=/usr/bin/ibus-daemon --xim -d
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
EOF
4. Build iBus Pinyin
4.1 Install Berkely Database
4.2 Download three files from
iBus libpinyin web site (https://sourceforge.net/projects/libpinyin)
- libpinyin source code
- model file (in this example, model15 is used)
- ibus-pinyin source code
4.3 Build libpinyin
extract the source code package and run the following commands:
cp ../model15.text.tar.gz data/
sed '51,51d' -i data/Makefile.am
./autogen.sh --prefix=/usr --disable-static
make
make install
Note: The above "cp" and "sed" commands are used to remove the "wget" instruction and copy the model file to the target folder so we can build the source codes in the offline environment.
4.4 Build ibus-pinyin
extract the sourc code package and run the following commands:
./autogen.sh --prefix=/usr --sysconfdir=/etc
make
make install
5. Test iBus for pinyin
If you run the command "gtk-query-immodules-2.0" (for GTK+ 2.x) or the command "gtk-query-immodules-3.0" (for GTK+ 3.x), you will find that iBus input module will be activated if the beginning of the system locale is "zh", "ja" or "ko" only.
Therefore, we have to use the systemd command "localectl" to set the correct system locale such as "zh_CN.GB18030". You can run "locale -a" to find out the available system locale and read the Chapter 6.2 (Glibc 2.27) of LFS 8.2 for more information.
Then, you can start the iBus configure panel and add "Pinyin" method in the list.
Now, you should able to switch iBus input method and input Chinese characters in your text editor (e.g. mousepad).