remapping keys on a SPECIFIC USB keyboard

Peter Hutterer peter.hutterer at who-t.net
Tue Apr 27 16:53:04 PDT 2010


On Tue, Apr 27, 2010 at 03:49:39PM -0700, Dirk Hohndel wrote:
> I use my laptop in several different locations - in one of them the
> keyboard that I connect to it is an Apple keyboard that has Alt_L and
> Multi_key (aka, Windows key but in that case, Option and Meta) reversed
> compared to all of my other keyboards. So instead of Ctrl, Multi_key,
> Alt_L as the three keys next to each other, I get Ctrl, Alt_L,
> Multi_key. 
> 
> Needless to say, this is a real pain for "muscle memory" when typing.
> 
> Is there a way to configure X to detect when this specific keyboard is
> connected (it identifies itself as Apple keyboard) and to remap those
> two keys?

yes and no, you can add config snippets based on the device name to apply
different XKB models and rules. for more info and examples, see
https://fedoraproject.org/wiki/Input_device_configuration

however, in this particular case you'll run into two issues:
 - I don't know off-heart if there are any xkb options that do exactly that.
 - if you're using e.g. GNOME, it will overwrite your settings with the
   session-configured xkb layout. so you'd need to disable the keyboard
   gnome plugin, or apply it manually.

you can also do it at runtime with setxkbmap, that supports a device id
(again, provided there's an xkb option for it)

Cheers,
  Peter



More information about the xorg mailing list