Xorg: multiple keyboards, one configuration

keyboard-layoutxorg

On my laptop, I tweak some keybindings and keyboard preferences with
xmodmap and xset. When I plug an external USB keyboard, the
configuration for that new keyboard is the default, i.e., without my tweaks.
If I xmodmap and xset again, then these preferences are applied to the
newly plugged keyboard too, but on pluging/unpluging, they are again reseted
to the default. Note that the pluging/unpluging never affects the
configuration of the laptop keyboard, which stay tuned during the whole
process.

Question: How can I have one xmodmap and xset preference set, which applies to any keyboard (plugged now and in the future).

Configuration: Arch Linux on 3.1.1 kernel, Xorg 1.11.2 with no
homemade configuration, window
manager: awesome 3.4.11, no kde or gnome stuff

Thanks!

Best Answer

@Patkos Csaba: It changed: now the default is that you don't have to configure anything at all and it works automagically. In a certain way, adding setxkbmap to .xinitrc became way easier than changing the server configuration.

Nowadays you can plug an USB keyboard or mouse and have X11 add it and recognize it, no need to rely on /dev/mice or something like that.

Now I've experienced the issue and, IMHO, the perfect solution would be some way to tell Xorg to inherit the new keyboard settings from the currently connected keyboard or to tell setxkbmap to set the options as the server default for current and future keyboards.

So far, I did not find any way to do so. The only way to avoid running setxkbmap/xmodmap again is to edit the default settings employed by hald when configuring new devices, see the freebsd documentation, ยง6.4.2 (some paragraphs below the section header, has two examples of setting keyboard defaults). See also "option 2" at Klaas Teschauer's tutorial on the hal migration. There's also a question on Stackoverflow with links about triggering a script on hardware additions, if you prefer to do it that way.

Related Question