Skip to content

Instantly share code, notes, and snippets.

@nilstoedtmann
Last active August 3, 2021 22:31
Show Gist options
  • Save nilstoedtmann/e9de2394194a6c8381a4daaf13b79919 to your computer and use it in GitHub Desktop.
Save nilstoedtmann/e9de2394194a6c8381a4daaf13b79919 to your computer and use it in GitHub Desktop.
Add German letters (diaereses/umlaut) and currency signs to English X11 keyboard layouts
// Nils Toedtmann https://github.com/nilstoedtmann 2017-01-25
//
// Add German letters (diaereses/umlauts and Eszett) and currency
// signs to selected English keyboard layouts on level3 (<AltGr>)
//
// Save as /usr/share/X11/xkb/symbols/deng. To load:
//
// setxkbmap deng # US-based
// setxkbmap 'deng(gb)' # UK-based
//
// In order to get listed in Gnome's/Unity's keyboard settings dialog,
// add the layout 'deng' and its flavour 'gb' to
// /usr/share/X11/xkb/rules/evdev.{lst,xml} and restart X. See
// https://gist.github.com/nilstoedtmann/e9de2394194a6c8381a4daaf13b79919
// for details.
//
// Tested with Ubuntu 16.04, X.org 7.7 and Unity 7.
default partial alphanumeric_keys
xkb_symbols "basic" {
include "us(basic)"
name[Group1]= "English (US, with German umlauts and currency signs via AltGr)";
include "deng(umlauts-on-latin-keys)"
include "deng(umlauts-on-german-keys)"
include "deng(currency)"
include "level3(ralt_switch)"
};
partial alphanumeric_keys
xkb_symbols "gb" {
include "gb(basic)"
name[Group1]= "English (UK, with German umlauts and currency signs via AltGr)";
include "deng(umlauts-on-latin-keys)"
include "deng(umlauts-on-german-keys)"
include "deng(currency)"
include "level3(ralt_switch)"
};
partial
xkb_symbols "umlauts-on-latin-keys" {
key <AC01> { [ NoSymbol, NoSymbol, adiaeresis, Adiaeresis ] };
key <AD09> { [ NoSymbol, NoSymbol, odiaeresis, Odiaeresis ] };
key <AD07> { [ NoSymbol, NoSymbol, udiaeresis, Udiaeresis ] };
key <AC02> { [ NoSymbol, NoSymbol, ssharp, section ] };
};
partial
xkb_symbols "umlauts-on-german-keys" {
key <AC11> { [ NoSymbol, NoSymbol, adiaeresis, Adiaeresis ] };
key <AC10> { [ NoSymbol, NoSymbol, odiaeresis, Odiaeresis ] };
key <AD11> { [ NoSymbol, NoSymbol, udiaeresis, Udiaeresis ] };
key <AE11> { [ NoSymbol, NoSymbol, ssharp, section ] };
};
partial
xkb_symbols "currency" {
key <AD03> { [ NoSymbol, NoSymbol, EuroSign, cent ] };
key <AC09> { [ NoSymbol, NoSymbol, sterling, NoSymbol ] };
key <AD06> { [ NoSymbol, NoSymbol, yen, NoSymbol ] };
};
@nilstoedtmann
Copy link
Author

nilstoedtmann commented Jan 25, 2017

  1. Save above file as /usr/share/X11/xkb/symbols/deng.

  2. Test with setxkbmap deng or setxkbmap 'deng(gb)'. Proceed if happy.

  3. Edit /usr/share/X11/xkb/rules/evdev.lst and add this to the ! layout section:

    deng English (US, with German umlauts and currency signs via AltGr)

  4. ... and this to the ! variant section:

    gb deng: English (UK, with German umlauts and currency signs via AltGr)

  5. Edit /usr/share/X11/xkb/rules/evdev.xml. Find the <layoutList> branch and add this entry:

    <layout>
      <configItem>
        <name>deng</name>
        <shortDescription>en</shortDescription>
        <description>English (US, with German umlauts and currency signs via AltGr)</description>
        <languageList>
          <iso639Id>eng</iso639Id>
        </languageList>
      </configItem>
      <variantList>
        <variant>
          <configItem>
            <name>gb</name>
            <description>English (UK, with German umlauts and currency signs via AltGr)</description>
          </configItem>
        </variant>
      </variantList>
    </layout>

  1. Restart X (logout/login, or --)

@nilstoedtmann
Copy link
Author

I can't find a script generating /usr/share/X11/xkb/rules/evdev.{lst,xml} from the contents of /usr/share/X11/xkb/symbols/. If there is none, why?

@nilstoedtmann
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment