Whenever I plug in a USB keyboard, the layout of all keyboards is reset to some system default (a US layout which doesn't have modifiers and other keys the way I want them). I've observed this on many Debian and Ubuntu systems, including Ubuntu 16.04 and 18.04. This behavior has been around for a very long time.
I use X11 with no desktop environment (though some Gnome demons tend to get started). I set my keyboard layout with XKB (specifically … | xkbcomp - "$DISPLAY"
) when I log in.
When I insert a USB keyboard, I want it to have my layout, not the system layout. In fact, I wish the system would just keep using my current layout for both the already present keyboard(s) if any, and the newly inserted keyboard. If that's not possible, I'd settle for re-applying a layout that I chose.
Likewise the repeat rate on both keyboards is set to the login-time default instead of the rate I set with xset r
.
How can I prevent a keyboard hotplug from resetting the keyboard layout and the repeat rate? Or failing that how can I at least make it reset to my chosen layout?
There's a fairly clumsy way which is with a udev rule. It's clumsy because it assumes that there's a single X server, and most problematically, it assumes that the user has root permission. I do not have root permissions, so any method that involves setting udev rules or editing Xorg.conf
is inapplicable here.
udevadm
and puttingudevd
in debug mode (udev tracing is no fun) find out what exactly happens. Once you found that out, you can think of ways to disable it. – dirkt Jun 08 '19 at 07:58inputplug -n -c /bin/echo
. – Jun 08 '19 at 09:01udev
rule actions won't show up in any log, which is whyudev
rule debugging is no fun. But this is where all starts - the kernel produces an event that a new input USB device is available, and whatever goes wrong and loads new keyboard layouts for all devices happens in userspace and is eventually triggered by this event. – dirkt Jun 09 '19 at 08:35xkbcomp
) just like you, I don't useinputplug
, but my own program; I've just learned about and testedinputplug
because of this Q, so I cannot vouch for it. YMMV. – Jun 10 '19 at 08:54