I am using xmodmap
(and sometimes xkbcomp
instead) to adjust my keyboard layout (e.g. mapping Caps Lock to the Mod3 modifier).
When I plug a USB keyboard into my laptop or insert a YubiKey (which acts like a keyboard), the settings for my laptop keyboard are immediately lost, leaving me in situations where Mod3 stops working and I cannot use my window manager any more.
How can I make my xmodmap
/xkbcomp
settings persistent or at least persistent per X session for my internal keyboard, so that it keeps the layout, no matter if I attach other keybaords?