5

I'm using xkbcomp to swap the Alt and Win keys on an Apple keyboard of mine.

This works:

xkbcomp -w0 -I"$DIR" "$DIR/keymap/mykbd" $DISPLAY

...but it changes the layout for all keyboards, and this will not do because I am frequently changing between a standing and sitting position (and swapping keyboards).

I have taken the trouble of specifying a device. The xkbcomp help text says: -i <deviceid> Specifies device ID (not name) to compile for

xkbcomp -w0 -I"$DIR" -i 16 "$DIR/keymap/mykbd" $DISPLAY

...but this seems to produce no effect!

I drew the id 16 from xinput list | grep Magic\ Keyboard. I've also tried /dev/input/event18 as an id, taken from xinput list-props 16 | grep 'Device Node', but this produces no better effect.

Update:

Suprisingly, when I provide the id of Virtual core keyboard instead of Magic Keyboard, I do get an effect: the new mapping gets applied to my Magic Keyboard, and if I proceed to type on my integrated laptop keyboard, the keymap then reverts to the original configuration.

I can't explain this. Does anyone have any insight?

Jellicle
  • 849
  • the id should be a number like 16 or 18, not a path like /dev/input/event18. doublecheck with xinput list that your hardware isn't presenting two separate entries. note these device ids aren't guaranteed to remain the same after reboot or unplug/replug. – quixotic Jan 11 '18 at 17:33
  • @quixotic : thanks for settling that. I did use the id 16 initially. And I have double-checked. (I acknowledge that these ids may change after reboot/unplug.) So the question remains why I get no effect when specifying -i <id> – Jellicle Jan 13 '18 at 01:06
  • I ended up customizing my keyboard by use of udev, writing a /etc/udev/hwdb.d/70-keyboard-local.hwdb file – Jellicle Aug 31 '20 at 16:52

1 Answers1

0

You may wish to employ the technique described here.

Alternatively, create a separate .xkb file for each device (could use method described here for each one) and place shortcuts for each on the desktop. Persistence wouldn't be as important since the expectation is that the key layout (device) would be selected manually.

u2n
  • 923
  • 1
  • 9
  • 22