You are not logged in.

#1 2016-04-28 05:56:51

murrcurt09
Member
Registered: 2015-12-02
Posts: 25

Remap Razer Naga side buttons to numpad

Hello,

I like to have my Razer Naga 2014 side buttons bound to the numpad instead of the line of numbers above qwerty,

I had it working previously by executing this script

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

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
    key <AE01>   {      [0xffca]       };
    key <AE02>   {      [0xffcb]       };
    key <AE03>   {      [0xffcc]       };
    key <AE04>   {      [0xffcd]       };
    key <AE05>   {      [0xffce]       };
    key <AE06>   {      [0xffcf]       };
    key <AE07>   {      [0xffd0]       };
    key <AE08>   {      [0xffd1]       };
    key <AE09>   {      [0xffd2]       };
    key <AE10>   {      [0xffd3]       };
    key <AE11>   {      [0xffd4]       };
    key <AE12>   {      [0xffd5]       };
};
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

which I found at https://bbs.archlinux.org/viewtopic.php?id=145502

I hadn't been using my naga for a while but recently I have been, and the above no longer works. I'm wondering if anyone can offer me a solution?

Thanks,

Offline

#2 2017-01-23 20:53:37

STiAT
Member
From: Vienna, Austria
Registered: 2004-12-23
Posts: 606

Re: Remap Razer Naga side buttons to numpad

Since this wasn't answered yet and I ran into the same issue today, I'll answer it now. I know bumping old threads is against the code of conduct, but in this case I'll ignore that.

First of all, the reason this happens is because for some reason Razer Naga Keyboard is found TWICE now (as are other input devices, as my keyboard). If anyone has an idea why the hell this happens I'd be interested in the reason, I couldn't find it, but it may be evdev related.

$ xinput --list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Razer Razer Naga 2014                     id=10   [slave  pointer  (2)]
⎜   ↳ Razer Razer Naga 2014                     id=11   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ Logitech Logitech G430 Gaming Headset     id=8    [slave  keyboard (3)]
    ↳ UVC Camera (046d:0809)                    id=9    [slave  keyboard (3)]
    ↳ Razer Razer Naga 2014                     id=12   [slave  keyboard (3)]
    ↳ Cherry USB keyboard                       id=13   [slave  keyboard (3)]
    ↳ Cherry USB keyboard                       id=14   [slave  keyboard (3)]
    ↳ Razer Razer Naga 2014                     id=15   [slave  keyboard (3)]

Making the commands fail.

Solution: Just go through the device IDs with a loop to set the values to both devices. The following script worked for me. Not sure if it's 100 % "clean", but it does it's job.

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

mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
    key <AE01>   {      [0xffca]       };
    key <AE02>   {      [0xffcb]       };
    key <AE03>   {      [0xffcc]       };
    key <AE04>   {      [0xffcd]       };
    key <AE05>   {      [0xffce]       };
    key <AE06>   {      [0xffcf]       };
    key <AE07>   {      [0xffd0]       };
    key <AE08>   {      [0xffd1]       };
    key <AE09>   {      [0xffd2]       };
    key <AE10>   {      [0xffd3]       };
    key <AE11>   {      [0xffd4]       };
    key <AE12>   {      [0xffd5]       };
};
EOF

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

Last edited by STiAT (2017-01-23 20:56:40)


Ability is nothing without opportunity.

Offline

Board footer

Powered by FluxBB