Sunday, December 30, 2007

» Disable middle mouse pasting (sort of)

Someone asked on IRC how to disable middle mouse pasting in X. Seems like it's a mystery to almost everyone as it's asked on quite a few forums but always left unanswered. I wouldn't want to miss that feature, personally, but well, here's a trick to disable middle mouse pasting in X:
  1. list your current mouse pointer X mappings using xmodmap -pp (look at the 2nd column)
  2. swap the button 2 with some unused one, typically the highest number
  3. add a line e.g. "pointer = 1 9 3 4 5 6 7 8 2" (if you have 9 buttons, for the sake of an example) to ~/.Xmodmap
Note that it will completely disable the middle key (but you'll still be able to use it to scroll as scrolling up and down is mapped to two other distinct pointers in X (4 and 5, actually)) To automate the process, just copy/paste the following snippet into a shell (and execute it):
xmodmap -pp |perl -ne 'BEGIN{@a=();$h=0} {next unless /^\s*\d+\s+\d+\s*$/; ($v)=/^\s*\d+\s+(\d+)\s*$/; push(@a,$v); if ($v gt $h) {$h=$v}} END{@b=();foreach(@a){ if ($_ eq "2"){push(@b,$h)} elsif($_ eq $h){push(@b,"2")} else{push(@b,$_)} }; print "pointer = ".join(" ",@b)."\n";}' >> ~/.Xmodmap

Labels: ,

1 Comments:

Blogger fourbit said...

Actually, I'm the guy that asked that. :D My Middle Mouse button has been acting up for a while. It has gotten very touchy in it's old age. When I would try to scroll with it, it would invariably click and paste the last contents in the browser address or wherever I was. That was getting very annoying. I had been looking for a solution to this for 3 weeks off and on.

I finally logged on to an IRC chat and Loki helped me though it!

I would just like to personally thank Loki for his assistance in this matter. The fix worked fantastically.

Your great.

Paul
Montana, USA

01:36  

Post a Comment

Links to this post:

Create a Link

<< Home