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?