I don't like having the middle mouse button paste, because I often end up with uncompilable code in Eclipse. How can I turn this off (in all programs)? I'm running Fedora.
How to turn off “middle mouse button paste” functionality in all programs
mousexorg
Related Solutions
You cannot map two physical buttons to the same logical button. All you can do is swap the buttons (echo 'pointer 1 7 3 4 5 6 2' | xmodmap -
). This is a low-level limitation of X11. As stated in the documentation of XSetPointerMapping
:
However, no two elements can have the same nonzero value, or a BadValue error results.
The best you can do is to use a program like xbindkeys
to send a fake button 2 press when button 7 is pressed. In .xbindkeysrc
:
"xdotool mousedown 2"
b:7
"xdotool mouseup 2"
b:7 + Release
Here is the Ubuntu Wiki entry on how to disable the middle mouse button. This should work on any system using X.
Example: Disabling middle-mouse button paste on a scrollwheel mouse
Scrollwheel mice support a middle-button click event when pressing the scrollwheel. This is a great feature, but you may find it irritating. Fortunately it can be disabled.
First, you need to know the id of the mouse, like this:
$ xinput list | grep 'id=' "Virtual core pointer" id=0 [XPointer] "Virtual core keyboard" id=1 [XKeyboard] "AT Translated Set 2 keyboard" id=2 [XExtensionKeyboard] "Macintosh mouse button emulation" id=3 [XExtensionPointer] "Logitech USB-PS/2 Optical Mouse" id=4 [XExtensionPointer]
My mouse has the Logitech logo printed on it, so I gather I need the last entry.
I can view the current button mapping thusly:
$ xinput get-button-map 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 10
Really, only the first three numbers have meaning for me. They represent the left, middle, and right mouse buttons.
$ xinput get-button-map 4
I can turn the middle mouse button off by setting it to 0:
$ xinput set-button-map 4 1 0 3
Or I can turn the middle-mouse button into a left-mouse button by setting it to 1:
$ xinput set-button-map 4 1 1 3
To make this set on a per-user basis, I can plug that line into my ~/.xstartup or other init file. It can also be done via configuring a matching InputClass section on xorg.conf.
The above example does not disable scrolling; if you want to do that see here.
Best Answer
This solution will work globally and preserve the middle mouse functionality.
Install
xbindkeys xsel xdotool
Place this in
~/.xbindkeysrc
Reload
xbindkeys -p
Run
xbindkeys
on startup,pkill xbindkeys
to stop.