Debian 9.5+ - Disable mouse button

Go root.
sudo bash

Install xinput to find out the available buttons.
apt-get install xinput

List inputs.
xinput list

You now get a list consisting of about two sections, in the Virtual core pointer section try to find the id of the mouse, it is noted as id=x.

Get the button map for the device.
xinput get-button-map <your mouse device id number>

You will get a long string like this:
1 2 3 4 5 6 7 8 9

Each number corresponds to a button it seems. Find out which one to disable by trial and error. Set one by one to 0 to disable it and enable the previously disabled one until you find that the button you want to disable is disabled, like this:
xinput set-button-map <mouse device id> 0 2 3 4 5 6 7 8 9
xinput set-button-map <mouse device id>  1 0 3 4 5 6 7 8 9
xinput set-button-map <mouse device id>  1 2 0 4 5 6 7 8 9

Note that the mapping string is without quotes.

When you know which one to disable, take note of the string that did it - the 1 2 3 4 5 6 7 8 9 string.

List connected USB devices:

Find the USB ID of the mouse - the xxxx:yyyy string in the list:
Bus nnn Device nnn: ID xxxx:yyyy Device name

Create the folder /etc/X11/xorg.conf.d if it does not exist.

In the folder, create a file named something like 98-disable-mouse-button.conf, fill it with:

Section "InputClass"
  Identifier "MouseWithDisabledButton"
  MatchDevicePath "/dev/input/event*"
  MatchDriver "libinput"
  # fill in your USB ID here
  MatchUSBID "xxxx:yyyy"
  # fill in your button string here
  Option "ButtonMapping" "1 2 3 4 5 6 7 8 9"

Save the file. To test if it worked you can restart the X server:
sudo systemctl restart display-manager


This is a personal note. Last updated: 2018-08-19 19:49:32.







Don't forget to pay my friend a visit too. Joakim