Simple way to disable mouse middle click paste in linux?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Simple way to disable mouse middle click paste in linux?
by on (#229211)
I did search on the subject in the past but in all thing linux, you find either too many answer and are not sure which one is appropriate (is it in X? is it something in the desktop manager? etc) or someone that will say something like "that's how it's supposed to work so why are you complaining about that?" kind of answer ^^;;;

I don't hate the feature, it just that I don't know how many time I just use the scroll wheel and all of a sudden, it just paste something in your current windows and causes havoc in it. One error I had was because some paste that didn't cause the code to fail and it just compiled properly and found later after scratching my head as to why some behavior changed.

I will search again soon on the subject but is there someone that disabled it because they didn't like it? Right now I'm using xfce but there is no option to disable it from the UI or I don't think I will find it since it's "normal".
Re: Simple way to disable mouse middle click paste in linux?
by on (#229213)
You guessed right: It is traditional for X11 applications to paste the primary selection when you press the middle mouse button in a text input control. The primary selection is the most recently selected text. It is distinct from the clipboard, which is what the Cut, Copy, and Paste commands access.

Have you tried Google Search for disable middle click paste? It lists an article on Make Tech Easier and answers by users of Ask Ubuntu. One solution uses xmodmap to disable all middle-click behavior, including opening links in new tabs. Another involves installing the xsel app and telling it to continuously erase the primary selection. Another works only in Firefox: in about:config set middlemouse.paste to false.
Re: Simple way to disable mouse middle click paste in linux?
by on (#229214)
I think that I must have ended on those pages when I searched with some similar terms. It just that when you have one solution that explain how to "erase the buffer" non stop, editing GTK source code to "fix" the issue etc, I didn't think there was a clear answer and just left it on hold "until I get too annoyed by it" state :lol:

I think I should just go with disabling middle click and that's it since I really don't use it much anyway. The thing is, I don't press the scroll wheel button: just scrolling activate randomly the press event, which means either the sensibility is too high or the mouse is getting older and some click are triggered, somehow.

I will check more about xmodmap then. I don't remember why I didn't go with it, maybe I had issue with it. I will try it again and see how it goes.

Thanks!

edit:

xmodmap seems to do the job since the middle button is now deactivated. I will check on next reboot if ~/.Xmodmap config is reloaded properly.
Re: Simple way to disable mouse middle click paste in linux?
by on (#229216)
Hmm. Yeah AFAIK it's an application level feature that most X11 apps implement independently like Tepples said, so I don't think there is really a way to disable it globally. There is a setting to disable it in the gnome tweaks tool for all GTK based apps (which is most of what I have on my machine anyway).

Image
Re: Simple way to disable mouse middle click paste in linux?
by on (#229217)
Off topic: when I first started using X11, the middle click paste was one of my favorite features. It's surreal encountering someone of the opposite opinion.

Older login managers did source one's $HOME/.xmodmap on login, but I wouldn't trust GNOME to not break that.
Re: Simple way to disable mouse middle click paste in linux?
by on (#229218)
@slembcke

I'm not using gnome at the moment so I cannot use that panel and since it's specific to GTK it may not disable for some of the app I use so I went with the extreme way: just disable it :P

@lidnariq

Like I mentioned, it's not that I "hate" the feature per say, it can be useful, but when just scrolling, no button press at all, causes the mouse to paste random text in the active view... That gets quite annoying after a while :lol:

So for the time being, for that specific computer which uses a mouse that it still working but seems too sensitive (maybe it's something with bluetooth or something else, who knows), it is better to just disable the feature than cursing every time you find a new place that text was pasted by accident.
Re: Simple way to disable mouse middle click paste in linux?
by on (#229261)
I am the opposite. I use the middle click paste, but I do not use the scroll wheel (so I have disabled the scroll wheel in .Xmodmap instead). (I would rather use a mouse without a scroll wheel, but I do not have one.)
Re: Simple way to disable mouse middle click paste in linux?
by on (#229267)
The last time I used a mouse without scroll wheel must have been in 97. It was a Logitech 3 buttons type and when scroll wheel became more common, I wasn't too fond of them.

Now I'm used but I guess it is just because it is very hard to find one without a wheel these days. Scroll wheel are a boon for joint pain, I guess :lol:
Re: Simple way to disable mouse middle click paste in linux?
by on (#229269)
I didn't even know this was a thing. I've sometimes missed clicking the bookmarks toolbar in Firefox and ended up middle-click-pasting the same url into the middle of itself in the address bar. Not a clue what was happening (other than maybe Firefox constantly putting the url in the clipboard or something).

Having just tried it in gedit, now I can copy/paste without having to use the keyboard. It also doesn't appear to move the cursor. I'm not certain, but this might help increase coding speed now that I know what's going on. Thank you.
Re: Simple way to disable mouse middle click paste in linux?
by on (#229270)
Glad to see that this topic somehow helped someone improve their productivity :lol:
Re: Simple way to disable mouse middle click paste in linux?
by on (#229450)
Banshaku wrote:
The last time I used a mouse without scroll wheel must have been in 97. It was a Logitech 3 buttons type and when scroll wheel became more common, I wasn't too fond of them.

Now I'm used but I guess it is just because it is very hard to find one without a wheel these days. Scroll wheel are a boon for joint pain, I guess :lol:


I've had a Kensignton Turbo Mouse trackball for like 10+ years. Best trackball you can buy for wrist issues IMO, but every couple years I have to dismantle it and clean out the optical scroll ring sensor. I've been lazy and just stopped using the scroll ring for at least two years now. Hehe.