I’ve had an annoying issue with the login screen on my Linux computer: it’s using the wrong keyboard layout. I can’t log in without first doing some mental mapping of where the keys are on the wrong keyboard layout. Here’s how you change the keyboard on the LUKS password screen, and graphical login screens.
I first noticed the issue after switching from GNOME to the Plasma Desktop. To get the full Plasma experience, I also switched from the GNOME Display Manager (GDM) to the Simple Desktop Display Manager (SDDM.) I believed the issue to be unique to SDDM, and focused my troubleshooting on finding out how to switch the keyboard layout in SDDM.
SDDM doesn’t read the keyboard layout preferences set in KDE System Settings. KDE’s settings app also doesn’t have a section for managing SDDM settings. So, I was kind of left with the traditional dance of rephrasing queries in search engines to find something relevant.
I couldn’t find a solution, however. I wasn’t really all that motivated to fix the issue. It was only an issue after boot. If the screen is locked, SDDM would use the active keyboard layout from my Plasma session for the unlock password prompt. (Surely, this must be a bug, right? It can’t be supposed to switch keyboard layouts like that? There isn’t even an indicator for which keyboard layout is active in SDDM!)
After a year with Plasma, I decided it was time to move back to GNOME and GDM. That’s when I realized the problem also affected GDM. This was even more puzzling to me. I’m sure it used the correct keyboard layout the last time I used it. Until this point, I had concluded that I was dealing with a bug in SDDM. GDM also having the same issue put me back on track of a configuration issue.
But what was misconfigured, though? The GNOME Control Center has language and region some settings for GDM and the login screen. What it doesn’t have, however, is a setting for the preferred keyboard layout.
So, where does it get this setting? The virtual console keymap was set to Norwegian through a boot parameter and in systemd. You can change this using the
sudo localectl set-keymap no command where
no (Norwegian) is your preferred keyboard layout. That affects the keyboard layout for the emergency boot console and the LUKS encryption password prompt during start-up. It doesn’t affect either GDM or SDDM, however.
After hours of searching, I finally found the answer in the GNOME System Administrator Guide. It doesn’t have an article describing how to choose the keyboard layout on the login screen. But it does have an article on how to display multiple keyboard layouts on the login screen. Close enough.
The article talks about how to change the X11 keymap preference. I’d seen this mentioned around on forums and elsewhere on the web, but I’d dismissed it. GNOME is using Wayland compositor and not the legacy X11 window server, after all. Configuration for X11 doesn’t affect Wayland, right? Well, it turns out that’s not the case when it comes to input preferences.
Wayland uses a software library called libinput to handle input devices and configuration. It’s still very much reading X11’s input configuration files. I did already know this from experience with some weird hardware input devices, but I failed to connect the dots.
Following the sysadmin guide article, I ran the following command and rebooted to see what would happen:
Lo and behold, it worked as advertised! Both GDM and SDDM now used the Norwegian keyboard layout as I desired. So, what did the above command do that I hadn’t already tried?
The command created a new configuration file in
/etc/X11/xorg.conf.d/00-keyboard.conf. It contained an input device called the system keyboard and set its
XkbLayout setting to
no. This all makes sense when you know what to look for.
I’m surprised and disappointed that the keyboard layout can’t be configured from within GNOME Control Center or KDE System Settings. SDDM changing the keyboard layout to match the Plasma session’s keyboard layout only when locking the screen is baffling. Surely, this must confuse and prevent people from unlocking their computers?
Most people have never given a second’s thought to what keyboards people from other places in the world use. They’d struggle to log in using a Cyrillic keyboard, for sure. But even switching from a U.S. or German to a French AZERTY keyboard layout would be a show-stopper for most people. Sure, it’s the same Latin alphabet but it’s also super-weird.
The Linux desktop is in good company on this one. MacOS also doesn’t have a super-obvious way to configure the keyboard layout on its login screen, and system updates keep arbitrarily changing it. My article on how to change the keyboard layout on MacOS is one of the blog’s most-read articles in recent years.