DEV Community

Cover image for Correcting iBus/X-Windows compose key conflicts
Paul Cochrane đŸ‡ȘđŸ‡ș
Paul Cochrane đŸ‡ȘđŸ‡ș

Posted on • Originally published at peateasea.de on

Correcting iBus/X-Windows compose key conflicts

Originally published on peateasea.de.

Did you know that iBus can cause the compose key to stop working in X-Windows on Linux? I didn’t either. The solution in my situation: if in doubt, leave it out.

I’ve been using Unix and Linux systems since the mid to late 1990s. This is a long time and old habits die hard. Lots of old habits in the Unix world still work today and thus they still have value. As the saying goes, “if it ain’t broke, don’t fix it”. Unfortunately, sometimes things break and it’s hard to work out why they broke and thus how to fix them.

Today is one case in point. I wanted to create a Euro currency symbol in an email but the compose sequence Compose e = didn’t work1. “Huh, that’s weird”, I thought. I tried the sequence in a terminal, which had worked up until recently (unfortunately, I don’t know exactly when 😕). It didn’t work there either. Very weird. I noticed that when pressing the compose key, a strange symbol, in what looked like a small window, appeared in my terminal. “Hang on, what’s that?”, I thought.

A couple of hours disappear, my browser history is much longer, and I still don’t have that email finished. But I now know what was causing the problem and I have a fix for it. Yay!

What’s the compose key?

Gollum saying:

But first: what’s this compose key thing he’s talking about? This is one way to create characters which might not be available on your keyboard. Being someone from an English-speaking culture, when growing up I didn’t need umlauts or accents or Greek characters on my keyboard.2 There are, however, very many other characters one might wish to use. The people who construct computing systems worked out a long time ago (relatively speaking) that a standard keyboard had too few keys for all possible characters one might want to produce. They came up with an elegant solution to this problem: characters could be composed by using a special key in combination with the more basic characters available on a keyboard. This became known as the compose key3 and (at least until the late 90’s and probably early 2000’s) there was a special key on many keyboards specifically for this task.

These days people tend not to use DEC or Sun Microsystems desktop systems (which is where one would have seen such a key) and thus it’s not obvious that a compose key could exist let alone realise that there might be a need for one. Since my standard keyboard doesn’t have an explicit compose key, I mapped caps lock to compose, because after all, who needs caps lock, right?

It doesn’t work! What, exactly, doesn’t work?

So, back to the issue at hand: the compose key wasn’t working. But what does “not working” mean in this case? Well, when I pressed the Compose e = key sequence the Euro currency symbol didn’t appear as expected. Instead, after pressing the compose key, a white box containing a little symbol appeared under the cursor:

Symbol appearing when compose key was pressed

The image shows my terminal prompt (which starts on the line below the username, hostname and path information that I display in my shell) and the cursor (the tall white box next to the -> arrow). Note that below the cursor, there’s a wide white box, with a grey shaded area to the left and within the white area there’s a symbol of some kind.4 Note how zoomed-in this image is. This is why it was very difficult to work out what the computer was trying to tell me and hence to work out what was going on. It seemed that this little pop-up box was stopping the compose sequence from getting to the shell and hence stopping the desired character from being displayed.5

This, I think, is the fundamental insight here: something was getting in the way and stopping the key presses from reaching the relevant (X-Windows) application. But what?

Trying to google for things like “little pop-up window when pressing compose key” led nowhere and served only to confuse me and make my browser history even longer.


 I thought something might be wrong with my xmodmap settings. Nope.


 I tried setting the XKBOPTIONS variable in/etc/default/keyboard and restarting X-Windows. Also nope.


 I even tried using a different windows manager.6 đŸ˜±


 I tried rebooting and 
 hang on, what was that? As the windows manager was starting, I noticed a symbol appear in the taskbar that I’d spotted before, but didn’t know what what it was. It looked a bit like a picture of a steam iron. It turns out it wasn’t a picture of an iron (and I never thought it was, but still). That idea came from either my bad eyesight, the small size of the icon, or my imagination (or a combination of all three). The icon was, in fact, a keyboard with a cable above and a small globe of the earth in the lower left-hand corner.

iBus initial icon in windows manager taskbar

Upon starting my first terminal session, this changed into just the two letters EN; this is because I use an English-based keyboard layout.7

iBus appearing as EN in windows manager taskbar

I’d seen this appear a few times over the years but it never seemed to have had any impact on my ability to enter text into the console or any GUI applications, so I paid it no further attention. I also noticed that the icon would sometimes disappear after a while. You know how one can be too busy to investigate that random thing which appears on one’s computer but later bites one on the proverbial posterior at some inopportune time? This was one of those times.8

Fortunately, this time, I decided I wanted to work out what this thing was and ended up right-clicking on the symbol, which greeted me with a context menu:

iBus context menu from windows manager taskbar

Clicking on the “About” menu item showed this window

iBus

Aha! Now I know what this thing is and can now create a more sensible Google query.

Extending my browser history (and the number of open tabs) further, I learned that the icon belonged to iBus, the “Intelligent Input Bus”. This is an

input method (IM) framework for multilingual input in Unix-like operating-systems.

In other words, one can use iBus to swap between, say, a German layout and an English layout.9 Since I’d already integrated umlauts and the sharp S into my keyboard layout via xmodmap, I didn’t need a system to handle more layouts. I thus tried simply quitting iBus from the “Quit” context menu item.

And then compose key sequences started working again! Yay!

Ok, now that I know how to solve the problem, how do I make sure that it doesn’t return?

Stomping on a bug

This wasn’t a bug in the sense that this was an error in code somewhere. It was, however, a behaviour that I didn’t want to have. Thus I could still use the same strategy as when confronted with a bug: after finding the root cause, ensure that the issue never resurfaces.

So what’s the long-term solution in this case? More stumbling through information on the internet showed that

ibus is the default input method (IM) for GNOME desktop. It allows a user to enter characters of a different language. E.g. entering Chinese while your system generally uses a German keyboard layout.

and that

im-config will set up [the] required environment variable and also take care starting of daemon program.

The im-config program configures the input method,10 of which iBus is one possibility. One configures im-config via the /etc/default/im-config file. The first few lines of this file look like the following:

# Default im-config mode (see im-config(8))

# This im-config helps to start best available input method (IM)

# Always start highest priority IM
IM_CONFIG_DEFAULT_MODE=auto
# Start or not to start IM dynamically under CJKV/desktop environment
#IM_CONFIG_DEFAULT_MODE=cjkv
# Never start IM by im-config (Leave it to desktop system)
#IM_CONFIG_DEFAULT_MODE=none

<snip>
Enter fullscreen mode Exit fullscreen mode

Isn’t it wonderful to read such a well-documented configuration file? It makes life so much easier.

Anyway, we can see that, by default, the highest priority input manager (IM) is started automatically.

# Always start highest priority IM
IM_CONFIG_DEFAULT_MODE=auto
Enter fullscreen mode Exit fullscreen mode

Further down, we can see that if we want to “Leave it to [the] desktop system”, we should change the IM_CONFIG_DEFAULT_MODE setting to none. Since we want to use the desktop system and not an intermediary, we comment out the line

IM_CONFIG_DEFAULT_MODE=auto
Enter fullscreen mode Exit fullscreen mode

so that it reads

# Always start highest priority IM
#IM_CONFIG_DEFAULT_MODE=auto
Enter fullscreen mode Exit fullscreen mode

and activate the line

#IM_CONFIG_DEFAULT_MODE=none
Enter fullscreen mode Exit fullscreen mode

(by removing the comment character) so that it reads like this:

# Never start IM by im-config (Leave it to desktop system)
IM_CONFIG_DEFAULT_MODE=none
Enter fullscreen mode Exit fullscreen mode

Saving the file and restarting X-Windows showed that iBus didn’t start, i.e. its icon doesn’t appear in the taskbar:

iBus deactivated after windows manager startup

Great! Problem solved! And I learned something!

Now I can close all of my browser tabs and finally finish writing that email. 😁

  1. Compose = e also works. See https://github.com/kragen/xcompose for a good .XCompose configuration. ↩

  2. And the Euro hadn’t been invented yet! Yes, fellow kids, I’m getting long in the tooth. ↩

  3. Also known as the Multi-Key. ↩

  4. It turns out that the symbol is the ISO composition symbol. I only worked this out much later though, basically because the symbol was so small when displayed on my screen. ↩

  5. My guess is that this is also why my email program wasn’t printing the Euro symbol: something was getting in the way of the compose sequence getting through to the email program. ↩

  6. My windows manager is awesome. No really, I mean it, it’s awesome. ↩

  7. I use an English layout on a German keyboard. I tend to confuse people who want to use my computer. ↩

  8. Perhaps my general disdain for ironing clothes had held me back from investigating what this icon was sooner. ↩

  9. The common iBus use case is to allow Japanese, Chinese and Korean (CJK) languages to enter non-ASCII native characters. ↩

  10. That’s the “im” in im-config. ↩

Top comments (0)