im-config for Debian Osamu Aoki In order to ensure im-config settings to be updated, you should restart the session or reboot the system. (Yes, you should be able to use systemctl but it is prone for problems.) This document provides only the top down view of the im-config package and how it is used with the input method packages. You should consult the im-config(8) manage for the details of this command behavior. ======================================================================= ! Introduction for setting-up input method for CJKV... ======================================================================= Although there are many ways to set up keyboard input method for non-European languages, let's start with the most basic one using GNOME desktop environment as an example. Please pay attention to the steps described in "Activate access to the installed IM engines". This is where most people get lost. Please note that there is no explicit configuration with im-config involved for GNOME desktop environment since im-config provides the sane default of doing nothing. This means that gnome-session and gnome-settings-daemon set up input method, and lets gnome-shell offer IM panel application. * Install packages listed below with their depended and recommended packages: * task-gnome-desktop * locales-all * ibus-gtk3 * ibus-wayland * libqt5gui * Font packages of the target environment - fonts-* (check Localization tasks) * IM engine client packages of your interest - Japanese, MOZC (best): ibus-mozc - Japanese, Anthy (good): ibus-anthy - Japanese, SKK (EMACS style): ibus-skk - Korean: ibus-hangul - Traditional Chinese: ibus-chewing - Simplified Chinese: ibus-pinyin - Simplified Chinese (SUN): ibus-sunpinyin - Simplified Chinese (Google): ibus-googlepinyin - Vietnamese: ibus-unikey - Many table based input method: ibus-table* * Activate access to the installed IM engines. * Press Super(=Windows)-key and type "Setting" to start the "Setting" dialog. * Click "Region & Language" * Click "+" at the bottom of "Input Sources". * Add your desired input method engine. For example, I may chose Japanese (Anthy) and Japanese (Mozc). * Configure IM engines to your tastes. * Reboot the system. Please note im-config doesn't check existence of IM library packages any more. If you want to use non-ibus IM framework such as fcitx and uim on the same system where ibus is installed or if you want to use non-GNOME desktop environment, then the explicit configuration with the im-config command may needed. ======================================================================= ! Basic design of im-config ======================================================================= 1. If an reasonable and single set of input method packages is installed, im-config activates it dynamically adjusted for all users by default. (recommended situation) 2. If several reasonable sets of input method packages are installed, im-config activates the most reasonable one dynamically for all users by default. (The locale, desktop system and other factors are taken into account.) 3. It provides a reasonably simple GUI configuration menu which may have been turned off on some system by the default. You can always start this simple GUI configuration menu by executing "im-config" from the console shell prompt. This shell script is internationalized via gettext.sh. Selected user configuration can override the system default configuration. Menu should normally show only available input methods on the system. 4. im-config package consists of 4 parts: 1) System start-up hook scripts and helper scripts * /etc/X11/Xsession.d/70im-config_launch --- (hook for X) - Set environment variables - Set /usr/bin/im-launch to $STARTUP to start daemon/GUI later * /etc/profile.d/im-config_wayland.sh --- (hook for wayland) - Set environment variables (source /etc/X11/Xsession.d/70im-config_launch with "$IM_CONFIG_PHASE" = 1) * /etc/xdg/autostart/im-launch.desktop --- (hook for wayland) - "exec env IM_CONFIG_CHECK_ENV=1 im-launch" to start daemon/GUI 2) Configuration files for the system start-up * ~/.xinputrc --- (user specific) * /etc/X11/xinit/xinputrc --- (system wide for root) * /usr/share/im-config/data/*.rc --- (IM specific preset values) 3) GUI configuration program to set up configuration files * /usr/bin/im-config This program also provides stable CUI API for other programs to interact nicely with im-config * /usr/share/im-config/data/*.conf --- (IM specific preset values) 4) Configuration files for the im-config default settings * /etc/default/im-config 5. Both user specific and system wide configuration files for the im-config package are sourced as POSIX shell scripts to perform 2 different tasks: * Set Environment variables: called with "$IM_CONFIG_PHASE" = 1 * XMODIFIERS --- for XIM protocol * GTK_IM_MODULE --- for GTK library * QT_IM_MODULE --- for QT library * ... * Start daemon and GUI programs: called with "$IM_CONFIG_PHASE" = 2 * daemon --- provide XIM server * GUI programs --- tray program etc. If these configuration files are generated by the GUI/CUI im-config program, they gave 3 lines like: --- # im-config(8) generated on Sun, 30 Mar 2014 02:45:02 +0900 run_im ibus # im-config signature: d57688c8151277a0c25d15aa0523da6b - --- run_im function looks for corresponding file to its argument "ibus", which is /usr/share/im-config/data/21_ibus.rc , and source it. The shell comment line contains signature to allow detection of manual modifications by /usr/bin/im-config which offers the menu configuration system. The menu configuration system honors such changes. ======================================================================= ! How To Configure Input Method with im-config ======================================================================= If you wish to override system default, For user configuration ~/.xinputrc, execute as: $ im-config For system wide /etc/X11/xinit/xinputrc, execute as: $ sudo im-config For system default: $ sudo -e /etc/default/im-config Under current GNOME3, type im-config after pressing SUPER(Windows)-key does the trick of starting the im-config GUI program. The default input method (IM) mode of im-config was simple but is a bit complicated now. Let me explain by going through its historical evolution. The IM_CONFIG_DEFAULT_MODE=auto choose the highest priority available IM. The IM_CONFIG_DEFAULT_MODE=none choose none of the available IM. So the initial default IM mode choices were: auto, none Since people setting CJKV locale environment may want auto mode while people setting non-CJKV locale environment may want none mode, the locale environment dependent automatic default IM mode IM_CONFIG_DEFAULT_MODE=cjkv was added to choose auto or none based on LANG environment variable value dynamically. Actual locales which qualify are defined in CJKV_LOCALES variable. With this, the default IM mode choices were: cjkv, auto, none Since modern DEs such as GNOME (both classic X and new wayland) integrate ibus as IM while providing panel GUI in its own desktop environment, im-config hook scripts needs to be disabled for ibus on such DEs. Such DEs to keep hands off are defined in DESKTOP_SETUP_IBUS variable in the /etc/default/im-config. DESKTOP_SETUP_IBUS='GNOME' The locale dependent package priority order override for auto mode is provided via IM_CONFIG_PREFERRED_RULE variable in the /etc/default/im-config. For example: IM_CONFIG_PREFERRED_RULE='zh_CN,fcitx' This means for zh_CN.* locale (LC_CTYPE), fcitx is chosen as the first choice over normal ibus if both are installed. In order to keep package priority of ibus over other IMs for DEs which integrate ibus tightly to DE, DEs specified by DESKTOP_SETUP_IBUS (namely real GNOME) are excluded to reorder using IM_CONFIG_PREFERRED_RULE. Please note CJKV_LOCALES, DESKTOP_SETUP_IBUS, and IM_CONFIG_PREFERRED_RULE can have multiple values. Some values can be preceded by "-" to indicate exclusion. Please make sure to separate them with ":" (colon). ======================================================================= ! How all these fit together ======================================================================= Initialization system for IM: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ibus fcitx, uim, SCIM Desktop GNOME desktop hooks im-config hooks MATE im-config hooks im-config hooks UKUI im-config hooks im-config hooks Unity im-config hooks im-config hooks KDE im-config hooks im-config hooks LXQt im-config hooks im-config hooks XFCE im-config hooks im-config hooks -- This is set by DESKTOP_SETUP_IBUS in 21_ibus.rc file IM package activation priority for auto mode: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Chinese Non-Chinese Desktop GNOME ibus -> fcitx ibus -> fcitx MATE fcitx -> ibus ibus -> fcitx UKUI fcitx -> ibus ibus -> fcitx Unity fcitx -> ibus ibus -> fcitx KDE fcitx -> ibus ibus -> fcitx LXQt fcitx -> ibus ibus -> fcitx XFCE fcitx -> ibus ibus -> fcitx -- This is set by DESKTOP_SETUP_IBUS, IM_CONFIG_PREFERRED_RULE in automatic_im function of xinputrc.common file Even if "ibus" is activated under GNOME desktop in the above, im-config hooks for "ibus" do nothing and leave initialization to desktop hooks. cjkv mode (Ubuntu default) behavior: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Debian Ubuntu Debian/Ubuntu en/fr/... en/fr/... zh/ja/... Desktop GNOME none auto* auto* MATE none auto auto UKUI none auto auto Unity none auto auto KDE none auto auto LXQt none none auto XFCE none auto auto -- This is set by CJKV_LOCALES, CJKV_DEFAULT_DESKTOP in mode_cjkv function of xinputrc.common file none mode meaning: ~~~~~~~~~~~~~~~~~~ Do nothing for IM by im-config hooks and leave IM to desktop hooks ========================================================================= ! Various input methods options ========================================================================= * IBus (GTK3, Qt5, Clutter, EMACS) -- popular and default for GNOME - Optional support packages - Clutter IM module: (optional) ibus-clutter - EMACS (optional optimization): ibus-el * fcitx (GTK3, Qt5) -- popular alternative IM framework for Chinese - Install all useful fcitx packages (use "l" under aptitude to find them.) - You may need to activate it by starting im-config from console and selecting "fcitx". - Reboot the system after configuration. * uim (GTK3, Qt5) -- popular alternative IM framework for Japanese - Install all useful uim packages (use "l" under aptitude to find them.) - You may need to activate it by starting im-config from console and selecting "uim". - Reboot the system after configuration. The status display dialogue is the uim-toolbar command. Its actual behavior can be customized by the selection of the update-alternatives command. (See update-alternatives(8) manpage) $ sudo update-alternatives --config uim-toolbar FYI: (With the method written in uim package, you can use toolbar under non-gnome environment) * SCIM - Install all useful scim packages (use "l" under aptitude to find them.) - You may need to activate it by starting im-config from console and selecting "scim". - Reboot the system after configuration. ======================================================================= ! New input method support ======================================================================= If you are interested to add a new input method support, please send me a start up code as *.rc and its matching *.conf for /usr/share/im-config/data by reporting to the BTS of the im-config package using reportbug(1). *.rc files contain the start up code for the input method. It contains 2 parts: IM_CONFIG_PHASE = 1 : export required environment variables to the programs launched via /etc/X11/Xsession.d/70im-config_launch for X and launched via /etc/profile.d/im-config_wayland.sh for wayland IM_CONFIG_PHASE = 2 : daemon/GUI start up code called from im-launch * via setting $STARTUP in /etc/X11/Xsession.d/70im-config_launch for classic X system. * via /etc/xdg/autostart/im-launch.desktop for wayland system which is active only under wayland system. *.conf files contain the definition of following variables and functions: Variables: IM_CONFIG_SHORT Short description of the im-config configuration. IM_CONFIG_LONG Long description of the im-config configuration. Sctipts are encouraged to use following internal variables. IM_CONFIG_LC_CTYPE Practically LC_CTYPE/LANG IM_CONFIG_CURRENT_DESKTOP Practically XDG_CURRENT_DESKTOP Functions: package_menu return true if required packages exist for menu listing level: 00-89 package_auto return true if required packages exist for auto selection level: 10-79 package_menu and package_auto use package_status function which returns true if the package given in its argument is installed. To test your proposed change, download the latest source by: $ git clone --branch devel \ https://salsa.debian.org/input-method-team/im-config.git Here, the "devel" branch is meant for everyone to commit changes. "master", "upstream", and "pristine-tar" branches are used to record the uploaded package by the maintainer with: $ gbp import-dsc --pristine-tar ../im-config*.dsc After above operation, I merge "master" branch to "devel" branch for my easy tracking of changes on the gitk screen. If you have debmake installed, you can make Debian package from "devel" branch with: $ make package ======================================================================= ! Note on source structure ======================================================================= This im-config package consists of 2 parts: * run time -- hook & desktop * configuration time -- im-config (GUI/CUI) Here are summary of each file usages. RUNTIME CONFIG hook & desktop im-config share/xinputrc.common.in INCLUDED INCLUDED share/im-config.common NOT-INCLUDED INCLUDED data/*.rc (contents) used not used data/*.rc (file name) used used data/*.conf (package_auto) used used data/*.conf (others) not used used -- Osamu Aoki , Sun, 19 Jul 2020 12:00:00 +0000 # vim: set tw=72 sts=4 sw=4 ai si et: