gnome/gtk: disable middle click paste via terminal

5,436

Solution 1

Underneath, Tweaks alters the dconf key

/org/gnome/desktop/interface/gtk-enable-primary-paste

You can do the same in terminal, either via dconf (e.g. to turn it off):

dconf write /org/gnome/desktop/interface/gtk-enable-primary-paste false

or via gsettings (e.g. to turn it back on):

gsettings set org.gnome.desktop.interface gtk-enable-primary-paste true

Solution 2

I had the same problem with the middle button pasting even though I turned it off in the dconf editor.

It turned out that the problem was only persisting in Mozilla Firefox and Thunderbird. They seem to have this functionality enabled by default as well.

This is how you can turn it off:

Firefox: Type about:config into the URL/search bar, click 'I accept the risk', search for middlemouse.paste and set it to false

Thunderbird: Go to Preferences > Advanced > General > Config Editor, search for middlemouse.paste and set it to false

Solution 3

This askubuntu.com answer using xdotool and xbindkeys seems to work as advertised on my Ubuntu 18.04 system.

The specific configuration maps the middle button (or scroll wheel) click to double-click on primary button which effectively stops the undesired paste action.

Quoting the askubuntu.com answer, for convenience:

OS: Ubuntu 18:04
Required Packages: xdotool and xbindkeys

you can install these packages with sudo apt install xdotool xbindkeys

gedit .xbindkeysrc

Paste the below content

"xdotool click --repeat 2 1"
b:2

Save the file and run xbindkeys --poll-rc

now your Middle Click should work as double click.

The original answer also addresses Unity differences.

Solution 4

I am not using Ubuntu, and I found an answer that also works on Centos here.

xmodmap -e 'pointer = 1 25 3 4 5 6 7 8 9'

If you have more mouse buttons, you keep adding them; this allows the pointer to be mapped to a different action, but middle mouse is kind of a pain now that we aren't using ancient mice with springs that require a kilogram of force. :)

Share:
5,436

Related videos on Youtube

jkbx
Author by

jkbx

Updated on September 18, 2022

Comments

  • jkbx
    jkbx over 1 year

    Configuration: Ubuntu 18.04 LTS, GNOME Tweaks 3.28.1 (I believe it's pre-installed in 18.04), Middle Click Paste: OFF

    Problem: It's not disabling middle click paste, although it worked once (until after the first restart with that option set to OFF).

    Question: What is the actual shell command that disables the MCP feature?

    Reasoning behind the question: I figured that GNOME Tweaks is executing that command by toggling that ON/OFF option and that it may use the wrong command now. This might be due to a dist-upgrade that changed the command.

    • jkbx
      jkbx about 5 years
      I am providing a partial solution to this problem. Using the gnome-tweak-tool the middle-click paste can be disabled for anything Gnome provides. However, it seems to be a convention of software developers to include the middle-click paste into their applications. For Firefox type about:config into the address bar, click away the warning, then search for middlemouse.paste and set it to false. For Pycharm, go to File, Settings, Keymap, Editor Actions, Paste from X Clipboard, remove the shortcut there. If this comment helped you, please upvote the question.
  • Michael Allan Jackson
    Michael Allan Jackson almost 6 years
    This isn't working in Ubuntu 18.04 (either through tweak UI or these cli commands). Any ideas what changed?
  • don_crissti
    don_crissti almost 6 years
    @MichaelJackson - it worked and still works fine here. I don't use Ubuntu.
  • Frank Kair
    Frank Kair over 5 years
    This answer is not relevant to the question. :(
  • Frank Kair
    Frank Kair over 5 years
    The question is specifically about Ubuntu 18.04. Your solution does not work in Ubuntu. Saying "I don't use Ubuntu" does not help either.
  • don_crissti
    don_crissti over 5 years
    @lolmaus-AndreyMikhaylov - not really, the actual question, if you read the post, is: "Question: What is the actual shell command that disables the MCP feature?" and my post answers exactly that question and not follow-up questions like "why doesn't this work in Ubuntu?"
  • Frank Kair
    Frank Kair over 5 years
    @don_crissti Please read the first three words of question body. Your command does NOT disable middle click paste on Ubuntu 18.04 (and earlier versions, for that matter). And if it did, Gnome Tweaks would work as well, so the command wouldn't be necessary in the first place.
  • Frank Kair
    Frank Kair over 5 years
    @don_crissti The point of my rant is that there are people looking for ways of disabling middle click paste on Ubuntu and Mint. On TrackPoint laptops (Lenovo & IBM) middle click paste is absolute nightmare. So people google for solution but are only able to find false solutions like yours to no avail.
  • don_crissti
    don_crissti over 5 years
    @lolmaus-AndreyMikhaylov - I never said my command disabled middle click paste in Ubuntu. There is absolutely no mention of Ubuntu in my post. Again, my post answers the question as stated by the OP. I can understand that you're frustrated but you should head to Ubuntu bug tracker and tell them to stop crippling GNOME (which is already crippled by birth...)
  • Frank Kair
    Frank Kair over 5 years
    "as stated by the OP" -- the acceptation was obviously a mistake by an inexperienced, one-time user. The information on how to disable MCP is available everywhere on the internet. The point of asking the same question for 1000th time here was that none of existing solutions (including yours) work in Ubuntu. This question is Ubuntu-specific. Did you earn your 47K rep by not reading questions and providing irrelevant answers?
  • don_crissti
    don_crissti over 5 years
    @lolmaus-AndreyMikhaylov - I guess so...
  • Inactivist
    Inactivist over 3 years
    For those wanting a workaround that actually works on Ubuntu 18.04, this seems to work on my test system: askubuntu.com/a/1195487/116968
  • DivyaK
    DivyaK over 3 years
    This is this only solution that worked for me on Ubuntu.
  • Turbotanten
    Turbotanten over 3 years
    Thank you for your explanation! This worked for me!