Saturday, October 29, 2016

How to Disable Annoying Paste Function of Mouse Middle Button

If there is one thing I really hate about my current GNOME desktop environment is its default paste function mapped to the mouse middle button. This is simply so annoying that I was looking for a way to get rid of this. After some trials, I have found one that actually works very well, and I would like to share it with anyone who is also having this problem. This post is based on this and this.

OK, so it tells me what input devices are connected. Under Virtual core pointer, I see my Microsoft Mouse, which is mapped to 11 and 12. In my case, it was the first device:

$ xinput get-button-map 11

3 2 1 5 4 6 7 8 9 10 11 12 13

The second number represents mapping of the middle button, so I simply disable it by setting it to 0:

$ xinput set-button-map 11 3 0 1

That's it. I now confirm that the middle mouse button no longer functions! Well, I want to keep it this way all the time, so I created a script$ echo "xinput set-button-map 11 3 0 1" > ~/disable_middle.sh$ chmod u+x ~/disable_middle.sh

I made it execute every time GNOME starts up by creating diable-middle-button.desktop file in ~/.config/autostart/ folder with the following[Desktop Entry]Type=ApplicationExec=~/disable_middle.shHidden=falseNoDisplay=falseX-GNOME-Autostart-enabled=trueName[en_US]=disable-middle-buttonName=disable-middle-buttonComment[en_US]=Comment=
Now, your mouse middle button will be disable every time you start up GNOME!