3

I have a Bluetooth "Camera Shutter" dongle. It emulates a Bluetooth keyboard. I've paired successfully, but I want to change how the buttons behave.

Currently, they're mapped to 123 (Volume Up) and 36 (Enter).

I'd like to change their mappings - but only for this Bluetooth keyboard. I want my laptop's keyboard to be unaffected.

My end goal is to have a Python program run when one of the keys is pressed.

Some things I found which didn't work:

I want to press "Volume Up" on my external keyboard and have a command run - without interfering with my internal keyboard's "Volume Up" key.

Any ideas? Ubuntu 14.04.4 LTS. Thanks.

0

As per https://superuser.com/a/869064/140864 - it's possible to use xkbcomp to change the assignment of specific keys.

remote_id=$(
    xinput list |
    sed -n 's/.*AB Shutter 3.*id=\([0-9]*\).*keyboard.*/\1/p'
)
[ "$remote_id" ] || exit

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
    key <VOL+>  { [ XF86Launch1 ] };
    key <RTRN>  { [ XF86Launch2 ] };
};
EOF

setxkbmap -device $remote_id -print | sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' | xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null

This needs to be run every time the device is connected. The keys can then be assigned to a specific shortcut action in Gnome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.