I have the following issue: I set the keyboard configuration with setxkbmap -model pc104 -layout us,ru,cz -variant ,,qwerty -option grp:shifts_toggle,terminate:ctrl_alt_bksp
in ~/.xprofile
, but after I unplug the (usb) keyboard and then replug it, my layout switching doesn’t work anymore, and I have to reexecute the above command to restore functionality. how can I solve this? I don’t want to have to execute the command every time. I have also tried to set the config via localectl, which stores it in 00-keyboard, but the result was the same.
Do not mix the two, do it only trough lcoalectl but make sure you do it properly:
localectl --no-convert set-x11-keymap us,ru,cz pc104 ,qwerty grp:alt_shift_toggle
remove the entry from ~/.xprofile
Despite I removed setxkbmap from xprofile and executed localectl --no-convert set-x11-keymap us,ru,cz pc104 ,,qwerty grp:shifts_toggle,terminate:ctrl_alt_bksp
(the corrected version), which resulted in:
❯ cat /etc/X11/xorg.conf.d/00-keyboard.conf
# Written by systemd-localed(8), read by systemd-localed and Xorg. It's
# probably wise not to edit this file manually. Use localectl(1) to
# instruct systemd-localed to update it.
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us,ru,cz"
Option "XkbModel" "pc104"
Option "XkbVariant" ",,qwerty"
Option "XkbOptions" "grp:shifts_toggle,terminate:ctrl_alt_bksp"
EndSection
I am unable to switch the layout from English to anything else using two Shifts without executing setxkbmap. I have rebooted as well to restart the X server.
In case you want a reproducible case, I should further specify that I use i3-gaps
with py3status
, the latter has a module called xkb_input
, which has a few backends. I am using xkb-switch backend, which appears to be a popular choice, in this fashion:
.config/py3status/config
:
xkb_input {
# install xkb-switch
switcher = "xkb-switch"
format_input = "{s}"
}
This brings me the ability to watch current layout in i3 statusbar. But I don’t think it interferes with layout settings.
Now, if I use xkb-switch -l
to list all layout groups, I only get us
. Once I execute setxkbmap I get us ru cz(qwerty)
, which is expected.
I described the above setup mainly to introduce xkb-switch -l
output, because that, and status bar not updating the layout, is how I know I cannot switch the layout.
It seems to be similar to what I experience. I have to setxkbmap on keyboard replug. But I also have to setxkbmap on X server launch.
Forgive me not explaining why I have the command in xprofile in the first place, I have been dealing with this problem for so long that I forgot what I did to make it less painful, and didn’t find any solution at that time.