I have a Dragon War Leviathan Gaming Laser Mouse (ELE-G1) and I wanted to use the extra buttons, which currently defaults as forward and backward buttons respectively, to switch between 2 workspaces.
This would have been a lot easier on Windows, but I’m using Linux Mint 18, which unfortunately has only support to customize keyboard shortcuts, and not mouse.
But after a couple of minutes of Googling, here’s how I was able to make it work on Linux Mint 18:
First, you need to find your mouse buttons’ number using xev.
You will see something like the following:
ButtonPress event, serial 25, synthetic NO, window 0x5c00001,
root 0x2c1, subw 0x5c00002, time 6921861, (29,37), root:(613,337),
state 0x0, button 1, same_screen YES
ButtonRelease event, serial 25, synthetic NO, window 0x5c00001,
root 0x2c1, subw 0x5c00002, time 6921899, (29,37), root:(613,337),
state 0x100, button 1, same_screen YES
Here, you can see the left mouse button as “button 1”. I didn’t include it in the sample results, but my mouse’s extra buttons were “button 8” and “button 9”.
Next, you need to install xbindkeys-config.
sudo apt-get install xbindkeys-config
Then print a default rc file:
xbindkeys --defaults > /home/exequtor/.xbindkeysrc
Next, open the xbindkeys-config window by simply:
And you will see something similar:
Now, add a new entry. You can leave out the name but on the “Key” field, enter the mouse button number, for example: “b:8” for “button 8”. On the “Action” field, enter the command you wish to bind. But for me, I wanted this to be Workspace 0, the default one, and the command is “wmctrl -s 0”.
You can add another entry. Just be sure you click the “Apply” button to save it. In my case, I added another entry for my “button 9” to use to switch on Workspace 1, and the command for this is “wmctrl -s 1”.
That’s it! Now, I can switch between my 2 Workspaces with my mouse’s extra buttons!