How to Disable Mouse Middle Click to Paste Feature in Linux

If you are not aware, in Linux, you can use the mouse middle click to paste content into your text documents. Together with a clipboard manager, this can be a very useful feature that allows you to do things more efficiently, except that it can also be very annoying at times.

For those with a sensitive mouse, you will find that everytime you scroll your mouse wheel too fast (which translate into a middle click), it will paste the previous copied content to your text editor, documents or any other input text field, without your knowledge. For writers, developers or anyone working on a written project, this is very frustrating.

As this is a system level feature, there are no easy ways to disable the mouse middle click to paste feature, but there are some workarounds/hacks that we can use.

One of the hack is to remap the mouse middle click button to other commands, like left or right click. This will effectively kill the middle-click to paste feature. However, this will also disable all middle click functions, so you won’t be able to middle click a folder to open in new tab in Nautilus, open new links or close a open tab.

1. Open a text editor and add the following text:

and save the file as “.Xmodmap” (without the quote) in your home folder.

Log out of your session and login again. Your mouse middle click will not be functional now.

If you are mainly working in the Firefox browser, you can deactivate the middle click to paste feature without losing your mouse middle click functionality.

On the URL bar, type “about:config“, press Enter and click the “I’ll be careful, I promise” button.

select for “middlemouse.paste“. Double click on it to change the value from “true” to “false”.


Unlike Firefox, there is no configuration options to turn disable the middle-click to paste feature. However, you can install the Autoscroll extension to remap the middle mouse button to autoscroll instead.

This particular hack involves patching the gtk source file and is meant for those experienced Linux users who know what they are doing. You will need to install a whole bunch of files and compiler code.

The following instruction was adapted from Assembla and modified to work for Gtk 3.0.

Open a terminal and type the following:

Next, grab the necessary files for compiling the code:

Download the patch file

Now, we are going to grab the gtk 3.0 source code

Apply the patch:

Recompile the source code:

Install the patched file:

The code above is meant for gtk 3.2.0. If your gtk version is different, change the version number above.

That's it. Log out and login again. The mouse middle-click to paste feature should be disabled now.

1. It is possible that any future update of the gtk code will override the changes. You might need to re-apply the patch again to disable the middle-click to paste.

2. This patch doesn't disable the middle-click to paste feature in Firefox. You still need to manually disable it in the about:config (see above).

3. I have tried this on Ubuntu Oneiric and it worked. I have not tried it on Ubuntu Precise (12.04).

This is another hack by Marco Ceppi. Rather than disabling the mouse middle-click to paste feature, it uses "xsel" to paste empty content when the middle button is clicked.

Here is the hack. First, install xsel:

Download this hack file and place it in your home folder.

Make it executable (Right-click -> Properties -> Permissions -> Allow executing file as program).

Create a new entry in the startup applications and add the following:

Note: This script will run an endless loop to detect mouse middle click and empty the copied content.

That's it.