Common input method
Cim stands for Common Input Method.
Input methods in Linux and BSD environments are currently fragmented. Applications and toolkits rely on different standards such as XIM, Gtk-IM, Qt-IM, and Wayland-IM, which makes integration complex and inconsistent.
Cim is designed to unify these disparate input method interfaces.
Instead of binding input methods to a specific GUI toolkit, Cim provides a toolkit-independent C API that applications and frameworks can use to access input methods in a consistent way.
Because Cim is implemented as a small C library with minimal dependencies, it can be used by:
- GUI toolkits
- terminal applications
- console programs
- sandboxed applications
- software written in different programming languages
This makes Cim suitable as a common foundation for text input across diverse environments.
Architecture
Cim uses a plugin architecture.
Applications link against the public Cim API library:
libcim.so
Actual input method implementations are provided by plugin modules.
/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
Each plugin implements the Cim input context API defined in cim.h.
Plugins may be implemented in several ways:
-
Native engine plugins Implement a full IME engine directly.
-
Framework bridge plugins Connect Cim to existing input frameworks such as ibus or fcitx.
-
Service-backed plugins Communicate with a daemon or external service.
Regardless of the implementation strategy, all plugins expose a small descriptor called cim_plugin, which provides a CimIcVTable describing how input contexts are created and managed.
Selecting the Active Plugin
The active plugin is selected using a symbolic link:
~/.config/cim/plugin
This link points to the desired plugin module.
Example:
mkdir -p ~/.config/cim
ln -sf /usr/lib/input.d/im-sample.so ~/.config/cim/plugin
To switch to fcitx:
ln -sf /usr/lib/input.d/im-fcitx.so ~/.config/cim/plugin
This mechanism avoids relying on environment variables, which may not always be present depending on the application startup context. It also makes it easier to build graphical configuration tools.
Using Cim
Once configured, applications or GUI toolkits simply call the Cim API.
When a CimIcHandle (input context) is created, libcim.so loads the selected plugin and delegates all operations to it.
Multiple input contexts can be created from a single plugin instance, and the plugin module is unloaded automatically when the last context is destroyed.
This design keeps the runtime lightweight while allowing flexible plugin implementations.
Integration with Existing Toolkits
Even if display servers or GUI toolkits do not adopt Cim directly, integration is still possible using bridge modules.
Typical environment variables:
QT_IM_MODULE="cim"
GTK_IM_MODULE="cim"
XMODIFIERS="@im=cim"
Example bridge modules:
/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
These bridges allow existing applications to use Cim without modifying the application itself.
Daemon-based Input Systems
Some input systems such as XIM or Wayland input methods require inter-process communication.
For these environments, Cim can use a daemon:
/usr/local/bin/cimd
Example daemon plugins:
/usr/local/lib/cimd/plugins/cim-xim.so
/usr/local/lib/cimd/plugins/cim-wayland.so
These components translate XIM or Wayland input events into the Cim API.
Benefits for Input Method Developers
Cim significantly reduces the integration burden for IME developers.
Traditionally, input methods must implement separate modules for:
- Gtk-IM
- Qt-IM
- XIM
- Wayland-IM
With Cim, an IME can support all of these environments by implementing the Cim input context API once.
Another important advantage is low-friction integration.
Many existing IME libraries (such as libhangul, librime, libanthy, or libpinyin) already provide core input context logic.
In such cases, a Cim plugin can often be implemented with only a small adaptation layer that exposes the existing functionality through CimIcVTable.
If upstream projects choose not to include Cim support directly, a standalone bridge plugin can still be implemented externally with relatively little code.
This flexibility allows Cim to integrate with existing input ecosystems without requiring large architectural changes.
Summary
Cim provides:
- a toolkit-independent input method API
- a simple plugin architecture
- low integration cost for existing IME implementations
- compatibility with existing input frameworks through bridge modules
By separating the input method API from GUI toolkits and display servers, Cim enables a more consistent and portable text input environment across Linux and BSD systems.
Technical Support for Cim / 1 year
Download
Cim is distributed as source code.
cim-2.0.0-2025.12.07.tar.bz2
cim-1.0.0-2024.01.25.tar.bz2
cim-0.0.1-2023.08.02.tar.bz2
cim-0.0-20230610.tar.bz2