I have a Logitech MX400 Laser Mouse which has 5 buttons + 4 for vertical/horizontal scrolling. I would like it set up so instead of horizontal scrolling pressing right on the scrollwheel will send Ctrl+Tab and left will send Ctrl+Shift+Tab, which will allow me to cycle through tabs in browsers.
Also, it would be nice if I could remap the middle button to one of the ones on the side as it is really hard to press down.
Another bonus would be if I could write a script that allows me to define what buttons do what dependent on which window is currently active.
I have tried using xmodmap
but I could only see how to rearrange buttons, not have them send key signals.
Thanks in advance.
Button Map (using xev
):
Left 1
Middle 2
Right 3
ScrollUp 4
ScrollDown 5
ScrollLeft 6
ScrollRight 7
Backward 8
Forward 9
The xbindkeys and xte can help you.
For example my .xbindkeysrc file looks like this:
Thanks to everyone for the solution. Here is a more foolproof/combined guide (done on Xubuntu 18.04).
Open a terminal (like xterm/terminal/terminator), become root (
sudo su -
) or use sudo in front of the command:Check the button mapping with
xev
, for this you don't need root permission so exit the root session (withexit
) or open another terminal as user.A small window will appear. You have to move the mouse into that window and press the button you want to remap. An example output in the terminal will be:
This is the 2nd side button on my mouse which I want to use as PAGE_DOWN.
This is the 1st (yes, the order is reversed) side button I want to use as PAGE_UP.
When you have all buttons you want to remap you can close the small xev window. Open your favorite editor (gedit/vi/nano for example) and edit the configuration file.
If you already have some content in the file, look if there is already a binding like it (unlikely, not by default) and add at the end.
Note: you need two entries, one for the button press and one for the release.
The buttons 8+9 will be mapped to the keys "Next" (which is PAGE_DOWN) and "Prior" (PAGE_UP). If you want to map different keys you can find the keysymbol with xev.
Like before, start it in a terminal, move the mouse to the small window and press the wanted key.
Save and kill xbindings.
You can now use the additional side buttons on the mouse. The setting will be loaded automatically on next reboot/login. You only need the
killall [...]
command from above if you change the settings.