Skip to main content

Disabling middleclick paste on Linux

Hi, have you also found it incredibly annoying and perhaps even a pretty big security issue that middle click pastes the last selected text on Linux?

Yeah, me too, so I've compiled a bunch of fixes that should hopefully disable this in many applications.

The main culprit seems to be X11 and Wayland (?), with them having multiple clipboards for selections and stuff.

As of writing, I use Linux Mint 22 Cinnamon, this should however be basically identical on most distributions.

GNOME Applications

In GNOME applications, you can disable this behaviour by installing the gnome-tweaks package and disabling "Middle Click Paste" in the Mouse & Touchpad tab of the installed program.

This sadly doesn't apply everywhere .-. (See "Elsewhere" section)

Discord

I've found that you can restore the autoscroll functionality in Discord by passing this argument: --enable-blink-features=MiddleClickAutoscroll

You can add this to your Discord shortcut, seems not even Vencord has a fix for this, even though I've seen a few suggestions in their github thingie.

However, that only enables the autoscroll and doesn't disable middle click paste, what a flop. See the "Elsewhere" section to disable everywhere.

Firefox

To enable autoscroll using middle click in Firefox, just open the settings (about:preferences), search for autoscroll and enable the "Use autoscrolling" option. You should also be able to find this option under the "General" tab, in the "Browsing" section of the page.

To disable middleclick pasting as well, follow the "Elsewhere" section of this guide.

Elsewhere

milaq/XMousePasteBlock

This project seems to be the best idea, as it clears the unwanted clipboard when clicking the middle mouse button to avoid pasting stuff.

Of course, a better way would be to just not have the stupid thing exist in the first place, but that would be wanting too much; even if such an update was to happen in X11/Wayland/whatever, your teeth would fall out from old age before you see a fix.

You'll need to build this project yourself. There are instructions in the repo. (still probably better than having 20 workarounds, at least in my opinion) After building this project, you can just put the "xmousepasteblock" command into your startup thingie, or install the .service file they give you.

I've also built this myself (on Linux Mint 22 Cinnamon, should probably work on any Debian distro), so I put it into my archive incase the project mysteriously explodes: download

- You can install this to path using: install -Dm 0755 "xmousepasteblock" "/usr/bin/xmousepasteblock", then just install the service file or add this to your startup.

I recommend just building it yourself though, it doesn't take long at all to run the few commands on the project's page to install dependencies for building and to just build it.

Ending

So yeah, those are the ways I've found, I now don't have this problem (:

If you still have the problem, just try restarting, if it still doesn't help, sorry, but you might have to search on the internet further. Good luck!

If you've managed to get this working, enjoy, hope I helped. (:

Links: