6

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.

jkf
  • 185
  • 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. – jkf Apr 14 '19 at 08:36

4 Answers4

4

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
don_crissti
  • 82,805
  • 4
    This isn't working in Ubuntu 18.04 (either through tweak UI or these cli commands). Any ideas what changed? – Michael Jackson Jun 20 '18 at 20:07
  • 1
    @MichaelJackson - it worked and still works fine here. I don't use Ubuntu. – don_crissti Jun 21 '18 at 06:50
  • This answer is not relevant to the question. :( – lolmaus - Andrey Mikhaylov Sep 21 '18 at 15:32
  • 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. – lolmaus - Andrey Mikhaylov Sep 21 '18 at 15:36
  • 1
    @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?" – don_crissti Sep 21 '18 at 15:49
  • @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. – lolmaus - Andrey Mikhaylov Sep 21 '18 at 19:51
  • @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. – lolmaus - Andrey Mikhaylov Sep 21 '18 at 19:54
  • @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...) – don_crissti Sep 21 '18 at 19:57
  • "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? – lolmaus - Andrey Mikhaylov Sep 21 '18 at 20:02
  • @lolmaus-AndreyMikhaylov - I guess so... – don_crissti Sep 21 '18 at 20:04
  • For those wanting a workaround that actually works on Ubuntu 18.04, this seems to work on my test system: https://askubuntu.com/a/1195487/116968 – Inactivist Sep 09 '20 at 13:17
2

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.

Inactivist
  • 130
  • 6
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

AdminBee
  • 22,803
1

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. :)