For the past few weeks, I’ve been struggling with a new keyboard I bought, a Logitech MX Keys, which I’m using via Bluetooth.
I’m used to always working with English keyboards, configured as international with dead keys. That means that to type accents and/or other special characters I need to press a key that doesn’t generate input, and then when pressing the next key, the character appears accented or with a diaeresis, etc. This is necessary for our special characters.
The issue was that I had everything perfectly configured. When starting up the computer everything worked fine, but after some time the configuration was lost and I ended up with a plain English keyboard. To get back to my config, I had to manually run the command:
setxkbmap us -variant intl
I couldn’t figure out why the configuration would randomly reset.
I’m using PopOS, with i3, and some configs I modify directly through gnome-control-center
. The keyboard was perfectly configured there.
To make the story shorter, I eventually discovered that what was changing my keyboard layout was the fact that the keyboard disconnected from Bluetooth. When it reconnected, it came back with a different layout (getting to this point took a while).
I got tired of asking Gemini and ChatGPT what could be happening—neither came close to giving me a concrete solution, though at least they helped me understand a few things.
In the end, I realized that:
- I needed to have the keyboard configured in X11
- I needed to configure the default keyboard
This way, it’s clear that some of the processes that run during the Bluetooth connection/disconnection are using those configs.
File: /etc/default/keyboard:
XKBLAYOUT="us"
BACKSPACE="guess"
XKBMODEL="logitech_base"
XKBVARIANT="intl"
XKBOPTIONS="lv3:ralt_switch,terminate:ctrl_alt_bksp"
The only thing I was missing was the XKBVARIANT
entry. Once I set it, it started working.
On the other hand, for X11, I created a keyboard config file with this info:
File: /etc/X11/xorg.conf.d/40-keyboard.conf
Section "InputDevice"
Identifier "Logitech MX Keys"
Driver "evdev"
Option "XkbLayout" "us"
Option "XkbVariant" "intl"
EndSection
After rebooting, everything came up perfectly. Disconnecting/reconnecting the Bluetooth keyboard also worked fine.
To validate:
$ localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
X11 Model: logitech_base
X11 Variant: intl
X11 Options: lv3:ralt_switch,terminate:ctrl_alt_bksp
$ setxkbmap -query
rules: evdev
model: logitech_base
layout: us
variant: intl
options: lv3:ralt_switch,terminate:ctrl_alt_bksp
Hopefully this helps someone out there.