I am writing a new custom keyboard layout for Xorg, but there is one particular glyph which does not exist in Unicode. It is, however, easy to create it by using a standard letter plus a combining diacritic mark.

For example, if I want the letter v with a macron below, the sequence U0073+U0331 creates the character that I want.

In my xkb layout definition, I can specify a single Unicode point (here altgr+d is bound to ḏ and altgr+shift+d to Ḏ):

key <AC03>  { [         d,          D,        U1E0F,        U1E0E ] }; // d with macron below

But I don't seem to be able to specify a 'combined' Unicode glyph for a single key:

key <AB04>  { [         v,          V,  U0076+U0331,  U0056+U0331 ] }; // v with macron below

Is it possible to create a system-wide xkb definition like this?

3 Answers 3



Still trying...

Testing shows that the keymap will ONLY take a single key in each position.

BUT, if you use a rare/never used keysym in the keymap definition, then a global Xmodmap to make THAT keysym output the various unicode characters you need, this'll work.

In the keymap:

key <AB04>  { [ v, V, XF86LaunchA, XF86LaunchB ] };

In a global Xmodmap: (perhaps loaded from /etc/profile.d ?)

keysym XF86LaunchA = U0056 U0331
keysym XF86LaunchB = U0076 U0331

There are quite a few unused/special-use keysyms, I chose the LaunchA/B as an example.

  • 1
    Thanks for the answer. One drawback is that this would be a per-use setting, right? Doing it with xkb would make it system-wide and means it can be distributed in a single file. Of course, those conditions were in my original question! Commented Jul 15, 2012 at 0:34
  • 3
    I dug through the source code, there doesn't seem to be any support for including multiple keystrokes in the key definitions of the keymap. Of course, you could rewrite it yourself to implement that ability!
    – lornix
    Commented Jul 15, 2012 at 3:29
  • 1
    Not the answer I wanted but that's the answer nonetheless. I'll poke around the source code a bit myself and look at the options you've suggested. Thanks. Commented Jul 15, 2012 at 4:02

On the other hand, you can attach to a given key the unicode combining diactityics character itself, and then you can type it after any other character. Indeed that is the way the unicode combining characters are suposed to work.

In X11 there are dead keys, dead keys work the other way: first the dead key, then the base letter. There is a <dead_belowmacron>, you can attach it to some key.

Then you need to edit the Compose file for your locale (if someone knows how to append definitions to Compose file from a user defined location I would apreciate), and add lines like:

# when the output is a single unicode char, you put also the corresponding
# X11 symbol name
# <symbol> <symbol> : "one-char-string" <symbol>
<dead_belowmacron> <d> : "ḏ" U1E0F
<dead_tilde> <n> : "ñ" <ntilde>
# when the output is a multicharacter string, you put just the string
# <symbol> <symbol> : "string"
<dead_belowmacron> <v> : "v̱"

the Compose file to use is defined by locale in the /usr/share/X11/locale/compose.dir file (path may vary).

  • I wish that worked, but as far as I can tell it doesn't: combining diacritics only seems to work when there's a single character for the character I need. For example, guarani uses both g̃ (g with tilde) and ỹ (y with tilde). The first is rendered in unicode as g with combining tilde, the second has its own character. When I try using the dead tilde to combine characters, the y works fine, but the g doesn't at all.
    – mmaluff
    Commented Jul 21, 2020 at 21:39

Update for 2020

This question was asked in 2012 with the latest answer (before this one) in 2013. For a long time now, the better answer has been to simply switch from xim to uim. It is a more-or-less drop-in replacement built to fully support Unicode and multi-lingual input. Among many other features, uim allows you to output multi-code point characters like U0073+U0331 as the result of a key press or a dead key combo.

  • 1
    How to use uim with xkb? I couldn't get much info on uim. (I am a complete newbie on xkb by the way) Commented Jan 5, 2021 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .