Easily Entering Umlauts With a US Keyboard Layout
As a software developer, a US keyboard layout is great for entering all the special characters you need while coding and for using certain applications like vim. But as a German speaker, I also frequently need to enter German characters that don't exist in English: the Umlauts äÄöÖüÜ and ß. I want to do this without giving up the US layout and without having to press complicated key combinations (no dead keys, no unintuitive combinations).
My goal is to get the German characters by holding right alt ("Alt Gr") while pressing the respective Latin character. E.g. ralt+a => ä.
Previous Approach: xmodmap
For the last years, I used the following `.Xmodmap` file, which could be applied by running `xmodmap .Xmodmap`:
keycode 39 = s S ssharp keycode 38 = a A adiaeresis Adiaeresis keycode 30 = u U udiaeresis Udiaeresis keycode 32 = o O odiaeresis Odiaeresis
This worked, but had two downsides:
- It only works with Xorg, but not with Wayland.
- The applied modmap got lost regularly (related to suspend or screen locking?), so I had to rerun `xmodmap` frequently.
New approach: xkb
Fortunately, there is a way that (despite its name) works for both Wayland and Xorg: setting up a user specific xkb configuration. Based on a detailed blog post[1] and a github comment[2], I created the following configuration:
File: .config/xkb/rules/evdev.xmlFile: .config/xkb/symbols/us partial alphanumeric_keys xkb_symbols "umlaut" { include "us(altgr-intl)" include "level3(caps_switch)" name[Group1] = "English (US, international with German umlaut)"; key us umlaut umlaut English (US, international with German umlauts) { [ e, E, EuroSign, cent ] }; key { [ u, U, udiaeresis, Udiaeresis ] }; key { [ o, O, odiaeresis, Odiaeresis ] }; key { [ a, A, adiaeresis, Adiaeresis ] }; key { [ s, S, ssharp ] }; };
If you prefer, you can also find the files in my dotfiles repo[3].
After restarting your desktop environment, you can select the keyboard layout and start using it. Under GNOME, you'll find it under Settings -> Keyboard -> Input Sources -> + -> English.
Alternatives
There's also the AltGr-wEur[4] keyboard layout, which fits the Danish, Dutch, Finnish, French, German, Italian, Norwegian, Portuguese, Spanish and Swedish characters all into a single keyboard layout without using dead keys. Combining all of these languages requires compromises, which results in the German ß not being on the S key but on number 8 key. If that's ok for you, this layout is a good choice.
Written on 2024-08-29. Last updated on 2025-02-06.