Custom xkb layout in which one key creates two unicode code points

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

EDIT:

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.

Method 2

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).

Method 3

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x