I use Trisquel GNU/Linux 7.0 LTS with GNOME 3 Flashback Environment.

I heard about three different input methods viz. ibus, xim and uim. And it seems ibus is pre-installed on my system.

$ cat trisquel_7.0_i686.iso.manifest | grep ibus
gir1.2-ibus-1.0 1.5.5-1ubuntu3
ibus 1.5.5-1ubuntu3
ibus-gtk:i386 1.5.5-1ubuntu3
ibus-m17n 1.3.4-3ubuntu1
ibus-table 1.5.0.is.
libibus-1.0-5:i386 1.5.5-1ubuntu3
libusb-0.1-4:i386 2:0.1.12-23.3ubuntu1
libusb-1.0-0:i386 2:1.0.17-1ubuntu2
libusbmuxd2 1.0.8-2ubuntu1
libustr-1.0-1:i386 1.0.4-3ubuntu2

While facing this problem I learnt about installing uim and setting up with GTK_IM_MODULE="uim" at ~/.profile. Recently I removed uim and removed GTK_IM_MODULE="uim" line from ~/.profile. But to overcome this bug, I am planning to get rid of ibus now.

Without installing any extra input-method, (say fresh-install of Trisquel), echo $GTK_IM_MODULE outputs xim So, I'm confused because considering default input-method is ibus, then why is $GTK_IM_MODULE saying xim?

Also can I apt-get remove ibus? or I should install uim first and then remove ibus? Also I want to know which input method is currently working ibus or xim? And What is the right way to set the input method (i.e is it GTK_IM_MODULE="uim" to ~/.profile)?

Besides,I found one gsettings scheme:

$ gsettings get org.gnome.desktop.interface gtk-im-module

Briefly/Broadly I need help to understand installing/removing and setting-up different input method:

  • How do I know which input-method is currently active?
  • How do I install and set-up different input-method? (should I remove another?)

The whole X11 input stack is a mess. First of all, you don't need any special input method framework if you're just typing latin characters or multi-character compose sequences as defined by your XKB keyboard layout. Strictly speaking, any multi-key sequences, such as dead-keys, require a very simple input method. But they are provided by libx11/XKB and work without any additional IM framework. So it is perfectly fine to uninstall all of ibus, uim, fcitx or whatever input method you have if you don't need to type languages such as Chinese or Japanese.

As you already said, Gnome made ibus the default input method, a decision not everybody was happy about. There are many people who prefer fcitx (which seems to be the default for most KDE distributions) over ibus for several reasons: be it proper language support (mostly Japanese vs. simplified vs. traditional Chinese) or performance issues. Since I don't speak any eastern languages which need a special IM framework, I can't really add anything to that debate. But if you are interested in more details about fcitx vs ibus, you may want to read this slightly dated (2012), but probably still accurate LWN article.

However, the fact that ibus is the default IM for Gnome doesn't make it obligatory. You can use any other input method you like or none at all. The IM configuration is done via environment variables. But except for when you're solely using GTK+ applications (which I doubt), you should set more than just GTK_IM_MODULE. The proper way of setting an input method is:

export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"
export XMODIFIERS="@im=fcitx"

in case of fcitx or

export GTK_IM_MODULE="ibus"
export QT_IM_MODULE="ibus"
export XMODIFIERS="@im=ibus"

in case of ibus. uim works in the same way. If you want to explicitly disable any input method, use these settings:

export GTK_IM_MODULE="gtk-im-context-simple"
export QT_IM_MODULE="simple"

An empty string works as well.

You can set these variables either system-wide in /etc/profile (or a dedicated file inside /etc/profile.d, respectively) or inside your local ~/.xprofile. Setting it in ~/.bashrc or ~/.profile will not ensure that the lines will be executed when logging into your system using a graphical login manager such as GDM, SDDM, KDM or LightDM. If you are starting your X session using XDM, Slim or startx, you need to put those lines in ~/.xinitrc.

If you configured an input method other than ibus, go to Gnome settings afterwards and make sure any ibus-related settings are disabled, especially any keyboard shortcuts. Alternatively, tell Gnome not to touch your keyboard settings using:

gsettings set org.gnome.settings-daemon.plugins.keyboard active false

or uninstall ibus altogether.

Now what about XIM? XIM is a pretty obsolete input method protocol which both ibus and fcitx implement for legacy support reasons only. There is no real reason why you would want to use XIM nowadays over any of those two. The only reason why you would want to set GTK_IM_MODULE="xim" is to override GTK's hardcoded ComposeKey settings.

To answer your other question: I don't think there is really a way of detecting which input method is active at the moment except for looking at the environment variables or knowing which IMs are installed on your system. If GTK_IM_MODULE is not set, GTK selects a built-in IM on the basis of configurations in /etc/gtk-2.0/gtk.immodules. GTK 3.0 looks in /usr/lib/gtk-3.0/3.0.0/immodules.cache which is generated by gtk-query-immodules-3.0.

The reason why GTK_IM_MODULE is set to xim is probably some stray variable definition somewhere in /etc/profile, /etc/profile.d/* or any other of your local or global shell RC files. Feel free to unset or override this variable if you feel the need to do so.

However, according to this Gnome bug report comment I assume that the value configured via gsettings overrides the value set in GTK_IM_MODULE for DBus-activated applications. So at least your Gnome applications are probably using gtk-im-context-simple at the moment which effectively means standard behavior (i.e. no ibus or any other dedicated IM).

  • Great explanation and background. Now if only gsettings didn't segfault on me whenever I try to do anything xD (even --version segfaults!!) – sqweek Jul 18 '17 at 9:41
  • So I have ibus and xim on my Ubuntu 18.04. Can I safely delete them both if I have no intention to type in CJK languages? – Suncatcher May 20 '18 at 14:55
  • Yes, but I wouldn't uninstall XIM unless needed. It's very dated, but sometimes used as base for other functionality. So unless you really need the few kB, I wouldn't uninstall it. – Janek Bevendorff May 20 '18 at 15:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.