Mapping G600 mouse extra keys in Ubuntu/Linux (Logitec)

Submitted by Too on Tue, 05/04/2021 - 15:46

1. We need to record special mouse keys codes:
sudo evtest
find the G600 mouse (if you have both, try them both, for me the second one was working with extra keys)

Noe start pressing the extra mouse keys, you will see something like this as a result in terminal:
Event: time 1529514948.076400, -------------- SYN_REPORT ------------
Event: time 1529514948.076400, type 4 (EV_MSC), code 4 (MSC_SCAN), value <b>7005c</b>
Event: time 1529514948.076400, type 1 (EV_KEY), code 122 (KEY_HANGUEL), value 0
Event: time 1529514948.076400, -------------- SYN_REPORT ------------
Event: time 1529514948.077380, type 3 (EV_ABS), code 41 (?), value 0

<b>7005c</b> is the key code that we need. You can map all other keys like this.
For me I got:
70059 - G09 key
7005a - G10 key
7005b - G11 key
7005c - G12 key
7005d - G13 key
7005e - G14 key
7005f - G15 key
70060 - G16 key
70061 - G17 key
70062 - G18 key
70056 - G19 key
70057 - G20 key

2. We need to create new HWDB rules file. Any name in specific directory:
sudo nano /etc/udev/hwdb.d/70-G600TOOPRO.hwdb

Write mouse hardware code (see below how to find it if standard didn't work for you) and then on the next line <b>after space</b> starting each line write mapping of the scan codes to key codes. We have list of the available key codes, and need to select one that we don't use in our life. On the <a href"">internet</a> Martin used Japan kodes, so we will do this too. All koed available <a href="">here</a>.

#evdev:name:Logitech Gaming Mouse G600:dmi:bvn*

3. Update HWDB
sudo systemd-hwdb update

4. Reconnect the mouse device (physically).

5. Check the key code using xbindkeys
write at terminal
xbindkeys -k

and then press needed button, you will get the result like this:
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    <b>m:0x10 + c:130</b>
    Mod2 + Hangul

We will use the bold code to our ".xbindkeysrc" file, by adding new entry for each button:

#G600: G12 - Copy
"xte 'keydown Control_L' 'key v' 'keyup Control_L'"
 m:0x10 + c:130 + Release
#G600: G13 - Paste
"xte 'keydown Control_L' 'key v' 'keyup Control_L'"
 m:0x10 + c:93 + Release

then to test, you can run:
xbindkeys -v -n
to debug, but not run daemon, if all ok, exit (ctrl+C) and then run daemon with command:

more to read:
you can run any script by:
    Control + c:75 + release

more info: