I own a Razer Naga Mouse, essentaly it has a small numpad on the side of it. I want to remap these keys to different unused keys or to bash commands. I can do this easily by using xev to grab the keycode (for instance the "1" on the mouse is keycode 87) and then I can use xmodmap to bind the keycode to a different key.
However the numpad on my keyboard will also inherit this as the keycode is the same, what I noticed though is that the "serial" is different.
For instance here is the output from xev when pressing the "1" button on my mouse numpad.
KeyPress event, serial 34, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179878, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179966, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and here is the output when pressing "1" on my keyboards numpad
KeyPress event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180261, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180341, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Is there anyway I could map the keys on my mouse based on this?
Instead of xmodmap
, try using setxkbmap
and xkbcomp
. The xkbcomp
command lets you specify an input device ID (using the -i
option).
To get a list of device IDs run xinput --list
. (FWIW, my Razer Salmosa was clearly labeled as "Razer Razer Salmosa".)
Here's how I converted my USB keyboard (ID 16) to use the German key mapping, while keeping my laptop keyboard on a US mapping:
setxkbmap de -print | xkbcomp - -i 16 $DISPLAY
I don't really know how to set up xkb
mappings, but I found a tutorial that looks pretty good.
Ok Solved. Follow instructions on this wiki https://github.com/graph/Razer-Naga-HotKey/wiki/How-to-get-Razer-Naga-HotKeying-Working-on-Debian
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With