Calamares is a Linux system installer used by dozens of distro’s to get the bits from an ISO image onto a target computer. Development is nowadays purely on a volunteer basis, which makes it hard to keep up with all the changes in the Linux world. But steps are made, and code submissions are very welcome, and here’s a note on something relatively new and useful: Wayland keyboard layouts.

Some History

In an X11-based system, the X server is the one thing that knows how to interpret keystrokes (pressing the button on a bit of hardware, e.g. the button to the right of the one labeled CapsLock is labeled A and makes the letter “a” when pressed). The X server can be told how to interpret the buttons: one command is setxkbmap which can manipulate the keymap:

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    ctrl:swapcaps

Using setxkbmap you can change the layout from the command-line: setxkbmap -layout us changes it to US-English, setxkbmap -layout ua changes it to Ukranian, and there’s tons of other layouts.

In Ukranian, pressing the keys labeled WASD yields “ЦФІВ”.

Changing the keyboard layout is just a matter of being connected to the X server – any X11 terminal program can do it, or an application can do it programmatically by sending the right X11 protocol messages.

Wayland

There isn’t a standardized mechanism in Wayland to request a different keyboard layout. It’s up to the compositor how and what it wants to do.

Some compositors are willing to listen to systemd’s locale1 service. KWin does this, but only when started with suitable command-line flags. Many systems that start KWin as part of their live installation do not pass that flag. Some compositors just don’t implement this at all.

KWin (Wayland)

The way to tell KWin to change the keyboard layout is to rewrite the configuration file for keyboard layouts in KDE Plasma, then send a DBus signal to KWin.

You can see that happening here, at least as of the code in April 2024. I suppose the idea is that the only way to change the keyboard layout is to go through the KCM, click on the list of layouts, manipulate it, etc. and then click apply.

For those cases when I briefly want to type Ukranian, or Arabic, that’s really annoying. For Calamares, which tries to set the keyboard layout when you select one, that’s really annoying.

Calamares and KWin

In the upcoming Calamares 3.3.10 release, the installer can be configured to edit KDE Plasma’s keyboard configuration file. I imitated the code from the KCM, but without relying on KConfig because that would be yet-another dependency for Calamares. This is a total bodge job. But it works!

For distro’s that use Calamares, and use KDE Plasma, and come up with a live system that uses Wayland (e.g. Asahi Linux) this means that keyboard layout updates can now be applied consistently, and you can e.g. type your password in the keyboard layout you’re actually going to use.

It ain’t pretty. Frankly, I think there should be a standardized way to say “use these keyboard layouts”, but I also understand that that opens the whole can of worms of “who should be allowed to change the keyboard layout?”.