Wednesday, December 10, 2014

Accénts & Ümlauts - A Custom Keyboard Layout on Linux

As a native English speaker living in Germany, I need to be able to reach the full Germanic alphabet without using long key combinations or (gasp) resorting to a German keyboard layout.

Accents and umlauts on US keyboards aren't only useful for expats. They're also enjoyed (or abused) by a number of English speaking subcultures:
  • Hipsters: "This is such a naïve café."
  • Metal heads: "Did you hear Spın̈al Tap are touring with Motörhead this year?"
  • Teenage gamers: "über pwnage!"

The standard US system keyboard layout can be enhanced to offer German characters via the following key mappings:
Key Key + Shift Key + AltGr (Right Alt) Key + AltGr + Shift
e E é É
u U ü Ü
o O ö Ö
a A ä Ä
s S ß ß
5 %

With openSUSE and some other Linux distributions, this can be configured by first defining the mappings in /usr/share/X11/xkb/symbols/us_de:
partial default alphanumeric_keys
xkb_symbols "basic" {
    name[Group1]= "US/ASCII";
    include "us"

    key <AD03> {[e,          E,           eacute,         Eacute]};
    key <AD07> {[u,          U,           udiaeresis,     Udiaeresis]};
    key <AD09> {[o,          O,           odiaeresis,     Odiaeresis]};
    key <AC01> {[a,          A,           adiaeresis,     Adiaeresis]};
    key <AC02> {[s,          S,           ssharp,         ssharp]};
    key <AE05> {[NoSymbol, NoSymbol,      EuroSign]};

    key <RALT> {type[Group1]="TWO_LEVEL",
                [ISO_Level3_Shift, ISO_Level3_Shift]};

    modifier_map Mod5   {<RALT>};

Secondly, specify the keyboard layout as the system default in /etc/X11/xorg.conf.d/00-keyboard.conf:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us_de"

Achtung!: IBus may be configured to override the system keyboard layout - ensure this is not the case in Ibus Preferences:
Once in place, the key mappings can be easily modified to suit specific tastes or languages - viel Spaß!

No comments:

Post a Comment

Comments are moderated due to spammer abuse.