9

I have a US keyboard and layout but sometimes I need german special keys (äÄöÖüÜß). Of course I could switch keyboard layouts when I need it but I used to abuse that uttery useless caps lock key to access the characters I need with the following ~/.Xmodmap:

keycode 66 = Mode_switch Multi_key
keycode 20 = minus underscore ssharp
keycode 34 = bracketleft braceleft udiaeresis Udiaeresis
keycode 47 = semicolon colon odiaeresis Odiaeresis
keycode 48 = apostrophe quotedbl adiaeresis Adiaeresis

For some strange reason the keyboard behavior has changed when Fedora switched to Wayland. Now my (magic) keyboard mapping only works sometimes and the caps lock key acts als case locker again :(

Is there a Wayland aware approach to make (german) special characters available on a US keyboard? (Or alternatively make []{}|<> available with one key stroke on a german keyboard)

2 Answers 2

13

Wayland uses XKB, but how to specify your layout varies based on your compositor (you can't use setxkbmap or xkbcomp as in Xorg). You'll probably want the altgr-intl variant of the standard us layout (US international layout) and possibly some options: Compose (aka Multi_key), perhaps on a Menu key? AltGr on the right Alt key? (The intl variant is similar but includes deadkeys on level 1; altgr-intl puts deadkeys on level 3, so they're out of the way but still accessible.)

Under this layout and variant, most of the symbols you've listed are available handily under the AltGr or Compose keys:

AltGr+q = ä   AltGr+Shift+a = Ä    Compose+",a = ä    Compose+",A = Ä
AltGr+p = ö   AltGr+Shift+p = Ö    Compose+",o = ö    Compose+",O = Ö
AltGr+y = ü   AltGr+Shift+y = Ü    Compose+",u = ü    Compose+",U = Ü
AltGr+s = ß                        Compose+s,s = ß

For Weston, you'd add settings to $HOME/.config/weston.ini:

[keyboard]
keymap_rules=evdev
keymap_layout=us
keymap_variant=altgr-intl
keymap_options=compose:menu,level3:ralt_switch

For sway (an i3-alike), you need to set environment variables before execution, either chained together on the commandline or in a helper script:

#!/bin/sh
export XKB_DEFAULT_LAYOUT=us
export XKB_DEFAULT_VARIANT=altgr-intl
export XKB_DEFAULT_OPTIONS=compose:menu,level3:ralt_switch
sway

Under GNOME, you'll have to consult your favorite gsettings or dconf frontend. You can specify XKB options in /org/gnome/desktop/input-sources/xkb-options and specific layouts in /org/gnome/desktop/input-sources/sources. (These may have changed since the post; check your existing settings.)

gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+altgr-intl')]"
gsettings set org.gnome.desktop.input-sources xkb-options "['compose:menu','lv3:ralt_switch']"

KDE uses its own graphical control panel; you'll find it in System Settings > Hardware > Input Devices > Keyboard. The Layouts tab will allow you to configure the altgr-intl variant (it's listed as "English (international AltGr dead keys)"), and the XKB options are listed on the Advanced tab.

On current KDE Frameworks 5, this control panel stores settings in $HOME/.config/kxkbrc.


If your system uses systemd's localectl you might try setting that to what you'd want, and GNOME/KDE might be able to pick it up from there. That may only set things for Xorg at present, but I like having it as a fallback, and I hope Wayland compositors will use it in future releases to pick up systemwide preferences.

sudo localectl set-x11-keymap us pc105 altgr-intl compose:menu,level3:ralt_switch
(format:                  [layout] [model] [variant] [options])
3
  • Modding org.gnome.desktop.input-sources.xkb-options w/ compose:menu via dconf editor worked for me, tyvm
    – lkraav
    Sep 14, 2017 at 14:59
  • Thank you. I would prefer "Windows style" composing, where there is no need to press a compose key. However this will do, and I could learn to use the 3rd level key.
    – Rolf
    Feb 17, 2018 at 12:43
  • @Rolf i'm not sure what you mean by "windows style", sorry. if you're referring to "deadkeys" (ie press ' then e to get é), that's the intl rather than altgr-intl variant. with deadkeys you have to press the deadkey twice to get the actual symbol, which is cumbersome for my use.
    – quixotic
    Feb 17, 2018 at 18:53
0

One possibility might be to change your default keyboard from English (US) to English (International). I do this on all the computers I have sufficient control over, and it lets me use some punctuation as "dead key" accents to get common non-English characters.

On Windows, this converts the right Alt key into AltGr, and combining this with certain keystrokes gets me related non-English characters, such as AltGr+s for sharp-s, AltGr+t for the Icelandic thorn, AltGr+d for the Icelandic edh, and others.

For "dead-key", most punctuation doubles as accents - to get e-acute, type ' then e; o-acute ' then o, a-grave ` then a, u-umlaut " then u, and so on. To get the punctuation, either press a character that it doesn't combine with as an accent, or press space - an apostrophe is ' then space; a double-quote/inch mark is " then space, and so on. It's a little bit of an adjustment, but a lot easier than memorizing alt-codes (on Windows) or continually switching between layouts.

(I've since done this in 'out-of-the-box' Linux Mint; modulo some minor differences in where some of the AltGr characters are located, ithas the same effect - but it's noy Wayland).

4
  • don't know why you've been down-voted...
    – frans
    Aug 25, 2017 at 16:23
  • @frans - Meh. Probably because "Wayland" is Linux, and I described the US-I keyboard on Windows. Aug 28, 2017 at 11:56
  • I wish I could do this in Linux.
    – Rolf
    Feb 17, 2018 at 12:44
  • @Rolf - I've since done it in Linux Mint, but I'd have to dig out that laptop when I get home and remember how - it's not, ttbomk, Wayland, but it does largely conform to my description above in its effects. Feb 17, 2018 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.