Make special characters available on US keyboard an Wayland

Solution 1:

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])