Configuring Side Buttons on Logitech Mice under Ubuntu Linux

One of the first things I modify on a desktop Linux install is to change the behaviour of the side buttons away from the defaults of “Back” and “Forward”.

Here’s a quick guide to changing the side buttons on a 5-button Logitech mouse on Ubuntu 12.04 through 19.04, and Linux Mint. It may work with newer versions, but has not been tested. This method also works well for most generic 5-button mice I’ve seen in the wild.

Install necessary packages

$ sudo apt-get install xbindkeys xvkbd

If your package manager can’t find xvkbd, an alternative is to install xautomation and use its ‘xte’ command in later steps.

Create a default profile for xbindkeys

$ xbindkeys --defaults > ~/.xbindkeysrc

Edit the default profile

$ gedit ~/.xbindkeysrc

Comment out the provided examples to prevent conflicts and strange behaviour.

# Examples of commands:
# control+shift + q
# set directly keycode (here control + f with my keyboard)
# c:41 + m:0x4
# specify a mouse button
# control + b:2

Add new entries in .xbindkeysrc for side buttons

The xev1 command will show you the index bound to each of your buttons (8,9). The snippet below works on the MX518 and M570.

# side button page down
"xvkbd -xsendevent -text "\[Page_Down]""
m:0x0 + b:8

# side button page up
"xvkbd -xsendevent -text "\[Page_Up]""
m:0x0 + b:9

Start ‘xbindkeys’, and confirm that your side buttons are working.

Make your changes take effect on Startup

In Preferences -> Startup Applications, create an entry to run xbindkeys.


Leave a Reply

Your email address will not be published. Required fields are marked *