Correcting iBus/X-Windows compose key conflicts
Tags: linux
Published: 2024-05-29 19:14:19

---
title: Correcting iBus/X-Windows compose key conflicts
published: true
date: 2024-05-29 18:00:00 UTC
tags: Linux
canonical_url: https://peateasea.de/correcting-ibus-x-windows-compose-key-conflicts/
cover_image: https://peateasea.de/assets/images/ibus-crossed-swords-x-windows-dev-to.png
---

*Originally published on [peateasea.de](https://peateasea.de/correcting-ibus-x-windows-compose-key-conflicts/).*

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 work<sup id="fnref:compose-equals-e" role="doc-noteref"><a href="#fn:compose-equals-e" rel="footnote">1</a></sup>. “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 :confused:). 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: "What's compose key, precious?"](https://peateasea.de/assets/images/whats-compose-key-precious.jpg)

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.<sup id="fnref:euro-not-exist" role="doc-noteref"><a href="#fn:euro-not-exist" rel="footnote">2</a></sup> 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 key](https://en.wikipedia.org/wiki/Compose_key)<sup id="fnref:aka-multi-key" role="doc-noteref"><a href="#fn:aka-multi-key" rel="footnote">3</a></sup> 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](https://peateasea.de/the-trick-with-perl6-and-linux-stay-composed/#mapping-mods-in-x), 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](https://peateasea.de/assets/images/compose-key-popup-window.png)

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.<sup id="fnref:official-compose-symbol" role="doc-noteref"><a href="#fn:official-compose-symbol" rel="footnote">4</a></sup> 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.<sup id="fnref:euro-symbol-also-not-in-email-program" role="doc-noteref"><a href="#fn:euro-symbol-also-not-in-email-program" rel="footnote">5</a></sup>

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`](https://wiki.archlinux.org/title/xmodmap) settings. Nope.

… I tried [setting the `XKBOPTIONS` variable in`/etc/default/keyboard`](https://duncanlock.net/blog/2013/05/03/how-to-set-your-compose-key-on-xfce-xubuntu-lxde-linux/) and restarting X-Windows. Also nope.

… I even tried using a different windows manager.<sup id="fnref:awesome-windows-manager" role="doc-noteref"><a href="#fn:awesome-windows-manager" rel="footnote">6</a></sup> :scream:

… 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](https://peateasea.de/assets/images/ibus-initial-icon.png)

Upon starting my first terminal session, this changed into just the two letters `EN`; this is because I use an English-based keyboard layout.<sup id="fnref:english-on-german-layout" role="doc-noteref"><a href="#fn:english-on-german-layout" rel="footnote">7</a></sup>

![iBus appearing as EN in windows manager taskbar](https://peateasea.de/assets/images/ibus-en-keyboard-selected.png)

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.<sup id="fnref:disdain-for-ironing" role="doc-noteref"><a href="#fn:disdain-for-ironing" rel="footnote">8</a></sup>

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](https://peateasea.de/assets/images/ibus-context-menu.png)

Clicking on the “About” menu item showed this window

![iBus "About" window](https://peateasea.de/assets/images/ibus-about-window.png)

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](https://explosm.net/comics/kris-tab) [tabs](https://www.hedgerhumor.com/close-a-tab-dont-be-ridiculous/)) further, I learned that the icon belonged to [iBus](https://en.wikipedia.org/wiki/Intelligent_Input_Bus), 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.<sup id="fnref:ibus-common-use-case" role="doc-noteref"><a href="#fn:ibus-common-use-case" rel="footnote">9</a></sup> Since I’d already integrated umlauts and the [sharp S](https://en.wikipedia.org/wiki/%C3%9F) 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](https://wiki.debian.org/I18n/ibus)

> 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](https://wiki.debian.org/I18n/ibus)

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

The [`im-config` program](https://packages.debian.org/stable/im-config) configures the _input method_,<sup id="fnref:im-in-im-config" role="doc-noteref"><a href="#fn:im-in-im-config" rel="footnote">10</a></sup> 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:

```shell
# 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>
```

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.

```shell
# Always start highest priority IM
IM_CONFIG_DEFAULT_MODE=auto
```

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

```shell
IM_CONFIG_DEFAULT_MODE=auto
```

so that it reads

```shell
# Always start highest priority IM
#IM_CONFIG_DEFAULT_MODE=auto
```

and activate the line

```shell
#IM_CONFIG_DEFAULT_MODE=none
```

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

```shell
# Never start IM by im-config (Leave it to desktop system)
IM_CONFIG_DEFAULT_MODE=none
```

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](https://peateasea.de/assets/images/ibus-deactivated.png)

Great! Problem solved! And I learned something!

Now I can [close all of my browser tabs](https://www.reddit.com/r/ProgrammerHumor/comments/g8b8i4/after_you_solve_that_mysterious_bug/) and finally finish writing that email. :grin:

1. `Compose = e` also works. See [https://github.com/kragen/xcompose](https://github.com/kragen/xcompose) for a good `.XCompose` configuration. [↩](#fnref:compose-equals-e)

2. And the Euro hadn’t been invented yet! Yes, [fellow kids](/assets/images/how-do-you-do-fellow-kids.webp), I’m getting long in the tooth. [↩](#fnref:euro-not-exist)

3. Also known as the _Multi-Key_. [↩](#fnref:aka-multi-key)

4. It turns out that the symbol is the [ISO composition symbol](https://en.wikipedia.org/wiki/Compose_key#History). I only worked this out much later though, basically because the symbol was so small when displayed on my screen. [↩](#fnref:official-compose-symbol)

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. [↩](#fnref:euro-symbol-also-not-in-email-program)

6. My windows manager is awesome. No really, I mean it, it’s [awesome](https://awesomewm.org/). [↩](#fnref:awesome-windows-manager)

7. I use an English layout on a German keyboard. I tend to confuse people who want to use my computer. [↩](#fnref:english-on-german-layout)

8. Perhaps my general disdain for ironing clothes had held me back from investigating what this icon was sooner. [↩](#fnref:disdain-for-ironing)

9. The common iBus use case is to allow [Japanese, Chinese and Korean (CJK) languages to enter non-ASCII native characters](https://packages.debian.org/stable/im-config). [↩](#fnref:ibus-common-use-case)

10. That’s the “im” in `im-config`. [↩](#fnref:im-in-im-config)