Common input method

Cim stands for Common input method.

Input methods in Linux and BSD are fragmented.
There are many input methods in Linux and BSD, such as XIM, Gtk-IM, Qt-IM, and Wayland-IM.

Cim is software that integrates these input methods.

Already, the Gtk input method and the Qt input method are plugin methods, and it has already been proven that there is no problem for decades when these plugin methods are used for input.

However, since the Gtk input method and Qt input method depend on Gtk and Qt, respectively, X-only, Java, Wayland-only, and console-only applications cannot use such Gtk and Qt input methods.

So I designed a common input method with C API by removing the dependency on Gtk from the Gtk input method.

Cim is made with C API and has no dependencies, so it can be used in various computer languages and applications.

How it works

cim.h contains interfaces and types.

  • Location of plugins

Place the input method plugins implementing the Cim input context API as follows:

/usr/lib/input.d/im-sample.so
/usr/lib/input.d/im-nimf.so
/usr/lib/input.d/im-ibus.so
/usr/lib/input.d/im-uim.so
/usr/lib/input.d/im-fcitx.so
  • The location of the symbolic link pointing to the plugin

It is recommended to select input plugins via a symbolic link rather than an environment variable. This is because an environment variable may not be set in some circumstances. Also, the symbolic link approach makes it easy to create configuration tools.

~/.config/cim.so is a symbolic link to the input method plugin like ibus, fcitx, nimf, uim.

ln -sf /usr/lib/input.d/im-sample.so ~/.config/cim.so
  • Try it

Now, when an application or GUI toolkit calls the Cim input context API, the input method works through it.

If you want to change the input method to fcitx, you can simply reset the symbolic link.

ln -sf /usr/lib/input.d/im-fcitx.so ~/.config/cim.so

In this way, XIM, GTK-IM, QT-IM, Wayland-IM, etc. can be replaced and integrated. However, there is a problem that input is not possible in Snap or Flatpak. If various applications or GUI toolkits call Cim input context API, the input problem in Snap or Flatpak can be easily solved by accessing $HOME/.config/cim.so.

Integration is practically possible

Even if applications such as Wayland, Snap, Flatpak, or GUI toolkits such as Gtk or Qt do not adopt Cim, input methods can be integrated in practice if various bridges that implement Cim are provided.

You need to set environment variables to use it this way.

QT_IM_MODULE="cim"
GTK_IM_MODULE="cim"
XMODIFIERS="@im=cim"

The following plugins can call third-party input methods such as nimf, ibus, fcitx, and uim via ~/.config/cim.so.

/usr/local/lib/gtk-4.0/4.0.0/immodules/libim-cim-gtk4.so
/usr/local/lib/gtk-2.0/2.10.0/immodules/im-cim-gtk2.so
/usr/local/lib/gtk-3.0/3.0.0/immodules/im-cim-gtk3.so
/usr/local/lib/qt5/plugins/platforminputcontexts/libqt5im-cim.so
/usr/local/lib/qt6/plugins/platforminputcontexts/libqt6im-cim.so

Since XIM and Wayland-IM require communication, a daemon(cimd) is needed. cimd can load cim-xim.so and cim-wayland.so, and they call the Cim input context API.

/usr/local/bin/cimd
/usr/local/lib/cimd/plugins/cim-xim.so
/usr/local/lib/cimd/plugins/cim-wayland.so

Actually, this is technically possible.
However, Flatpak and Snap applications can use input methods via ~/.config/cim.so. If that’s not possible, you’ll need to contact the Flatpak and Snap developers.

Benefits to input tool developers

Assuming that the Cim implementation includes the above plugins and daemon, even if the input tool(IME) developer does not implement Gtk-IM, Qt-IM, XIM and Wayland-IM, just implementing Cim input context API will enable typing in Gtk, Qt, X and Wayland applications.


Download

Cim is provided in the form of source code.

cim-1.0.0-2024.01.25.tar.bz2
cim-0.0.1-2023.08.02.tar.bz2
cim-0.0-20230610.tar.bz2