Disabling middle mouse paste Linux

The “middle mouse button paste” behavior of X11 can lead to posting unwanted text in a document when you’re simply trying to scroll through it.

disable middle-mouse button paste in Linux

  1. In Terminal, type:

    xmodmap -pp
    

    This will tell you the active mouse button function indices. The second number is apparently the middle mouse button function, which we will map to an unused index. Example output of xmodmap -pp:

    There are 10 pointer buttons defined. 
    Physical Button      Button Code 
    1                    1 
    2                    2 
    3                    3
    4                    4 
    5                    5 
    6                    6 
    7                    7 
    8                    8 
    9                    9 
    10                   10
    
  2. In terminal:

    nano .Xmodmap
    

    and swap the last number with the second number. Keep a backup of your original .Xmodmap file if one existed. For the example above, edit and save:

    pointer = 1 10 3 4 5 6 7 8 9 2
    
  3. Logout and back in

the middle-mouse paste should be disabled, while you are still able to use the middle mouse button to scroll.

Reference

Categories:

Updated: