So I have this esoteric problem that I have 2 totally different keyboards. The Happy Hacking Pro 2 (HHK) and the Realforce 103U. The happy hacking has a special, SUN inspired layout with the control key where standard keyboards usually have their caps. My Realforce 103U has a standard US layout. I am big fan of the old SUN layout and cannot type on keyboards that have the CTRL key on the usual position.
The problem: If I plug in my Realforce, I want to have the CAPS remapped to CTRL. If I plug in my Happy Hacking, it should stay the way it is!
Solution: Xorg Udev Matching
So in recent Xorg versions you can use udev matchings to select the options for a particular keyboard. On my Fedora 16, I added the following file:
$ vim /etc/xorg.conf.d/01-realforce.conf Section "InputClass" Identifier "Realforce" MatchProduct "Realforce 103U" Option "XkbLayout" "us,de" Option "XkbOptions" "grp:menu_toggle,ctrl:swapcaps" EndSection
Done. If I plug in my Realforce I have the ctrl and caps key swapped!
Bonus: As the win key on my HHK is right of the alt key I better switch ALT and WIN on my Realforce, too:
Option "XkbOptions" "grp:menu_toggle,ctrl:swapcaps,altwin:swap_lalt_lwin"