Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I add a custom compose key sequence?

For example, I would like Compose, |, > to type the symbol.

I have tried adding the following to ~/.XCompose:

# Import default rules from the system Compose file
include "%L"

# Custom definitions
<Multi_key> <bar> <greater> : "▸" U25B8 # Black right-pointing small triangle

but the new sequence is not usable anywhere except for xterm.

Installing ibus-table-compose and then enabling the Compose input method in IBus did not solve the problem; IBus imitated many compose key sequences, but not the one I had created.

share|improve this question
How do you type the symbol now? You could probably map the command you use to type the symbol to specific keys in keyboard layout. To find the exact keysym of a particular key, you can use xev . But ofcourse, this is just my guess. – Nitin Venkatesh Jun 7 '11 at 15:52
@nitstorm I typed it by pressing AltGr+>, which is a customized mapping that I set by adding the keysym U25B8 to keycode 60 in ~/.xmodmaprc. I'm not asking how to type ▸; I'm asking how to create a compose key sequence for it. – ændrük Jun 7 '11 at 16:05
up vote 11 down vote accepted

Do this first:

Create a file ~/.XCompose (that is a file named .XCompose in your "home" folder) which contains the following:

include "%L"   # import the default Compose file for your locale
<Multi_key> <bar> <greater>     : "▸"

See man 5 Compose for more info about the format of this file.

Then add export GTK_IM_MODULE="xim" to your .profile file and restart X.

share|improve this answer
I noticed that with this solution, I cannot use Ctrl-Shift-u anymore to insert unicode characters by number; so I take it that this switches something general away from the Gnome stuff to the X stuff which is configured by that ~/.XCompose file. Is there also a way to modify the Gnome stuff instead? I'd like to keep that Ctrl-Shift-u feature. – Alfe Jan 28 '13 at 15:31
@Alfe Using UIM as suggested on the bottom of Ubuntu Forums: .XCompose file not read in 11.04 GNOME works for me with the default settings in Debian jessie/sid (see im-config(8) for customization). That is, .XCompose settings are working both in GTK (GNOME) and Qt (KDE) applications, and .XCompose and Ctrl+Shift+U are both working in GTK applications (like Eclipse). – PointedEars May 10 '13 at 16:22
Thank you! So did you just apt-get the uim package or did you have to configure something else? – Alfe May 10 '13 at 19:59
I tried to get this running for some time now, but to no avail. It'd be very helpful to hear what exactly you did besides installing the uim package. At least this could help to be sure that your way doesn't work on Ubuntu 12.04. – Alfe May 10 '13 at 22:32
@dan_waterford Hi, I just asked this question here, and had it "possible duplicate"'d to this question. However, I've tried your answer and couldn't get it to work. Any ideas? :) – Owen_R Nov 15 '13 at 17:42

Create a file ~/.XCompose (that is a file named .XCompose in your "home" folder) which contains the following:

include "%L"   # import the default Compose file for your locale
<Multi_key> <bar> <greater>     : "▸"

See man 5 Compose for more info about the format of this file.

share|improve this answer
Neat! Is there any way to have this file re-read without restarting X? – Jeremy Kerr Jun 8 '11 at 7:10
This sounds promising, but my ~/.XCompose file doesn't seem to have any effect even after rebooting. Have you gotten this to work? – ændrük Jun 8 '11 at 15:49
@Jeremy: I'm not sure, but maybe changing the keyboard layout to another layout and then back might work. – JanC Jun 9 '11 at 12:52
@ændrük: I seem to remember that Gtk/GNOME stupidly messes with the compose key settings (you can test if the new Compose key combination works in e.g. xterm to confirm this is the case). I seem to remember the workaround had something to do with selecting an alternative input method that bypasses the problematic medling; maybe ask a new question about that, because it's not only useful for this but IIRC it also fixes locale-specific Compose maps, etc. ;) – JanC Jun 9 '11 at 13:14
Actually, this question is probably relevant. – JanC Jun 9 '11 at 13:36

On Ubuntu 14.04 I did the following:

1) Installed uim using the Software Manager, other packages like uim-xim, uim-gtk2, uim-gtk3 and uim-qt are auto installed. See

2) Defined environmental variables by adding the next lines to ~/.profile, this way the custom compose key sequences only apply to the current user:

# Restart the X-server after making alterations using:
# $ sudo restart lightdm
# It seems only GTK_IM_MODULE or QT_IM_MODULE needs to be defined.
export GTK_IM_MODULE="uim"
export QT_IM_MODULE="uim"

The ~/.XCompose-file from the OP should work after restarting 1) Ubuntu or 2) just the X-server by runnung the following command in a terminal:

$ sudo restart lightdm

NB: Restarting only seems necessary after altering the ~/.profile file, alterations to ~/.XCompose will take effect the next time an application (Terminal, Gedit, etc.) starts.

To check whether the environmental variables are set right, enter the following command in your terminal:

$ printenv | grep IM_MODULE

Many thanks to:

About custom compose key sequences:

About custom keyboard mapping:

Example .Xcompose files to mimic Window US International keyboards:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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