Task: Adapt an xorg/X11 keymap to your personal needs. To be specific, let us add European special characters (German umlauts, accent dead keys, euro sign) to the standard ASCII keyboard us
. The modified keymap shall be called us_de
.
Solution: (1) Create a difference file us_de_diff
. (2) Create an overarching file us_de
that calls in both us
and us_de_diff
. (3) Test with setxkbmap. (4) Make us_de
permanently known to the operating system.
The following example extends the US ASCII keyboard by the following ALT keys:
Save the following as /usr/share/X11/xkb/symbols/us_de_diff
:
default partial xkb_symbols "basic" { key <AE01> { [ 1, exclam , dead_grave ] }; key <AE02> { [ 2, at , dead_circumflex ] }; key <AE03> { [ 3, numbersign , dead_acute ] }; key <AE04> { [ 4, dollar , dead_diaeresis ] }; key <AE05> { [ 5, percent , dead_cedilla ] }; key <AE06> { [ 6, asciicircum , dead_caron ] }; key <AE07> { [ 7, ampersand , section ] }; key <AD03> { [ e, E , EuroSign ] }; key <AD07> { [ u, U , udiaeresis, Udiaeresis ] }; key <AD09> { [ o, O , odiaeresis, Odiaeresis ] }; key <AC01> { [ a, A , adiaeresis, Adiaeresis ] }; key <AC02> { [ s, S , ssharp ] }; key <AB03> { [ c, C , ccedilla ] }; key <AB01> { [ z, Z , guillemotleft ] }; key <AB02> { [ x, X , guillemotright ] }; };
Save the following as /usr/share/X11/xkb/symbols/us_de
:
partial default alphanumeric_keys xkb_symbols "basic" { include "us" include "us_de_diff" name[Group1]="en_US"; key <RALT> { type[Group1]="TWO_LEVEL", [ ISO_Level3_Shift, Multi_key ] }; modifier_map Mod5 { <RALT> }; }; xkb_symbols "nodeadkeys" { include "pc/en_US(basic)" include "pc/latin(nodeadkeys)" include "us_de_diff" };
Use the command
setxkbmap -layout us_de
to test the new key binding.
Edit the appropriate config file. Changes will become effective with the next upstart of the X11 server.
Current X11 versions: Modify the XKBLAYOUT entry in /etc/default/keyboard
.
Old X11 versions: Modify the following section in /etc/X11/xorg.conf
:
Section "InputDevice" [...] Option "XkbLayout" "us_de" EndSection
Please inform me if other distribution need to be configured in different ways.
Maintained by Joachim Wuttke.
First published in the German Linux-Magazin 10/2003, under the title “Deutsch-Amerikanische Freundschaft”.
Revised version for X11R7 published online 2006.
Revised version for X.Org versions without xorg.conf, 3 March 2012.