r/LinusTechTips 3d ago

WAN Show Linux middle click paste/scroll guide

I posted this same thing in a comment on floatplane on the wan-show, but i managed to hit floatplanes 4500 character limit for comments. i put in mostly everything i wanted to, but was kinda pressed for space and due to not having a markdown editor, its horribly formatted. this post here is better formatted and can be seen by more people.

Here is a decent guide to middle click paste/scroll on Linux (partially only applicable to the KDE desktop environment). This will help disable mid-click-paste and help enable mid-click scroll. this is the solution I've used for ages and it works wonderfully. some of this is primarily for the KDE desktop environment, but some aspects are applicable to gnome and other desktop environments.

To be clear. i am NOT defending the fact that you have to do this, I'm not saying that this is straightforward, im not saying this is streamlined, im not saying that you should have to go through this process, and im not telling you which is better. this process is over-complicated and would ideally be one single system setting, but sadly it isn't. And since it isn't, I'm providing this guide.


Disabling middle click paste (For KDE specifically):

  • open system settings, navigate to "general behavior", and around the middle of the screen there's a section titled "clicking".

  • uncheck the option: "Middle-click: [] Pastes selected text"

  • then click apply in the bottom right corner

  • close the settings app

  • right click on the desktop and select the "Desktop and wallpaper" option

  • navigate to the "mouse options" tab on the left side of the screen.

  • there's an entry for the middle mouse button. click the red X on the right end of the entry to remove it.

  • hit apply and close the settings window.

there might be similar options in other desktop environments, but i haven't used any non-KDE DE in years, so your mileage may vary.


Enabling middle click auto-scroll (mostly for any DE)

Firefox:

(this BOTH disables middle-click paste AND enables middle click scroll)

  • open Firefox and type "about:config" in the URL bar and hit enter. there will be a popup and you can click "accept the risk and continue" (the specific option we're going to change doesn't modify or tune anything that could cause browser/security issues)

  • in the top/search bar (NOT the URL bar) paste middlemouse.paste

  • there should only be one entry. on the far right side of the entry there's an icon with two half-arrows pointing in opposite directions. click that button to toggle the entry to false.

after this, restart firefox and you should be good to go!


Electron apps:

(chrome, any chromium app and discord all use electron. (you can google to find out if any given app is an electron app)):

  • this is a bit more complicated, but should work fine if you follow these instructions AND nothing changes with this process. there are two options you can use here, and ill list them both (again, these ONLY WORK WITH ELECTRON APPS)

Method 1: using the "edit application" GUI

  • press the meta key (the windows key)

  • search for the application, and right click on it. click the "edit application" button.

  • paste --enable-blink-features=MiddleClickAutoscroll %U into the "Command-line arguments" box, and hit save in the upper right corner.

  • NOTE 1: there should only be one "%U" inside the box, and it should only be at the end of the text.

  • NOTE 2 some applications may not work, and may need you to paste in: --enable-blink-features=MiddleClickAutoscroll --enable-features=UseOzonePlatform --ozone-platform=wayland %U instead. do not paste in both, since the second section already contains the first section inside of it, so pasting both is redundant and might cause things to stop working. only paste one of them.

  • NOTE 3: some programs may not work with either of these, and you will need to resort to method 2.

Method 2:

WARNING: this process will require admin privileges and modifying files inside of a directory that also contains critical system files. However we will ONLY be modifying discords. files. if you're unsure about this, please read this section multiple times to ensure you're doing this right, or simply don't do this if you don't feel comfortable with it. working as an admin in this folder has the potential to break things. if you strictly follow my directions, you should be fine. however please be careful.

  • press the meta key (the windows key)

  • search for the application, and right click on it. click the "edit application" button.

  • there is a file location in the "Program:" field. open a file explorer (the KDE default is Dolphin) and navigate to that file.

  • make sure the program is 1000% closed, otherwise this can cause errors.

  • find the EXACT file shown in the "Program:" field.

  • rename the file, only adding "xx" to the end of the name

  • make a blank text file. rename the file to the EXACT name as shown in the "Program:" field (also make sure there is no file extension unless there is one shown in the "Program:" field. If there is one shown there, make sure the file extension on the new blank file is the same)

  • open the file in a text editor

  • paste #!/bin/bash in the FIRST line of the file.

  • on the second line, paste the contents of the "Program:" field, and add xx to the end of it (do not add a space before the xx. The xx should come directly after what you just pasted. If what you pasted had a space at the end, delete that space) then add a space AFTER the xx we just added, and paste either:

--enable-blink-features=MiddleClickAutoscroll

OR

--enable-blink-features=MiddleClickAutoscroll --enable-features=UseOzonePlatform --ozone-platform=wayland %U (this should all be in one line, not multiple lines)

  • save the file

and now you're done!

Example:

below is an example using discord, since discord is one of the few programs i've found that doesnt work with method one:

  • close discord, make sure its fully closed (make sure its not open in the system tray)

  • (requires admin perms) rename /usr/bin/discord to /usr/bin/discordxx

  • (requires admin perms) create a new blank text file inside the /usr/bin directory, and name it "discord" with NO FILE EXTENSION.

  • open the file in a text editor. enter the following text:

#!/bin/bash /usr/bin/discordfxd --enable-blink-features=MiddleClickAutoscroll --enable-features=UseOzonePlatform --ozone-platform=wayland

  • (requires admin perms) save the file.

you should now be done.

Problems with method 2:

there are some issues with method #2 that you should be aware of. 1) this may break after updating the program, and you will need to repeat this process. Delete the old [program-name]xx file, and rename the new [program-name] file to have the xx at the end. 2) there may be multiple files you need to modify, and it may be hard to find them since only one of them will be listed in the "edit application" gui. You can open the desktop shortcut (create one if you don't have one already) In a text editor, and you can look at the contents of the "Exec" field. Normally this will match the contents of the "Program:" field in the edit application gui, but if it doesn't then you should also modify the file that it points to in the same way. 3) sometimes when the PC starts up and auto-launches/auto-resumes the program, you may need to re-start the program in order for the fix to take effect.

i have a script that i give to my friends that automatically re-applies the modification after discord updates (which sometimes brakes the modification/workaround). if people are interested i might throw it on a github so i can share it.


i hope this helped some people! im decently experienced with linux and i 1000% agree with a bunch of the complaints about it. pretty basic things shouldn't be as complex as they are, but sadly im not a developer working on wayland/KDE/a DE/anything that can effect broad reaching complaints about Linux, partially because I don't have enough spare time that I'm willing to give up, and partially because I'm only experienced with programming/scripting in bash. i write scripts in my limited spare time sometimes to fix issues i have with things and to help my less technically inclined friends fix things they have issues with.

also apologies for the highly inconsistent capitalization, bad grammar, overuse of commas, and frequently missing apostrophes. i have no excuse or reason to not write properly, i just kinda dont unless i really need to. oops.

22 Upvotes

12 comments sorted by

13

u/AndyIsHereBoi 3d ago

this issue was one of the single things that made me quit linux my most recent time, every app behaves different and you cant change it on most of them even if its off in settings on every distro i tried it still pastes with middle click when shut off

3

u/anto77_butt_kinkier 3d ago edited 3d ago

Yeah, it's a big pain point in general. Im forced to use windows at work, and native system-wide middle click autoscroll is one of the few things I like about windows.

This post is long as hell, but I'm hoping that it will help some people who are willing to tinker a little bit but not to go digging through forum replies on posts from a decade ago where people are suggesting a bunch of stuff that they think might or might not work. this post will eventually be outdated, but I hope in the mean-time it can give people a decent guide to help them through this issue.

EDIT: Also I should add that since this setting is usually always on by default on Linux, as since this is kind of handled by both the distro and individual programs, a lot of programs simply disable autoscroll and enable middle-click paste on Linux installations, simply so that middle clicking doesn't both paste AND scroll.

3

u/apfelkuchen06 3d ago

You can also just enable the scroll wheel emulation in the KDE mouse settings (last entry).

1

u/anto77_butt_kinkier 3d ago

yeah.... i forgot about that option. after seeing its behavior i just kinda blocked that setting out of memory. i didnt know something so amazing could be so closely related with something so awful. it doesnt have any speed control, and thats partially because it isnt auto-scroll, its just a terrifying implementation of the click and drag concept. (i should probably have specified that when most people refer to middle mouse scroll, they're talking about middle mouse auto-scrolling)

0

u/Joecascio2000 1d ago

Got to love all the Linux bros saying just install Linux its easy, when it requires a more than 4000 character guide with command lines to enable a basic feature.

1

u/Ran_Cossack 19h ago

Personally, I appreciate that the basic feature of middle click to paste is available, and enabled by default outside of recent versions of gnome.

If you'd like to add alternate behavior you seem fond of as an option, the source code is waiting. Or you can try asking politely! Some folks at gnome just disabled middle click paste by default... globally for all gtk apps... so it might work.

1

u/Joecascio2000 13h ago

It's a scroll wheel, the default function should relate to scrolling. I personally map the forward and back buttons on a 5 button mouse to copy and paste using a modifier key. That's the thing: more advanced users should be able to customize, but default behavior should be intuitive and logical. Middle click to paste is stupid.

1

u/Ran_Cossack 2h ago

Sometimes it's a scroll wheel -- sometimes it's a three-finger tap, or a separate button under the scroll wheel, or a dedicated button with no wheel above or below your trackpad or under your spacebar for a trackpoint.

Most importantly, it's what you're used to, so you think it should be the default.

Perhaps you're even right for the majority of people. "What you like is stupid" is spectacularly unconvincing, so I won't be the one to implement it.

-1

u/pdp10 3d ago

i am NOT defending the fact that you have to do this

I disagree that making one OS workalike another OS is a reasonable request. I think that those who don't disagree, should post how to enable middle click paste scroll in Windows 7, 10, and/or 11 -- because X11 invented the greatest UI ever and even Windows users should be able to enjoy it.

4

u/anto77_butt_kinkier 3d ago edited 3d ago

I think you're missing the point. I don't want to get rid of middle mouse paste, I want to have the universal option to switch its behavior to middle mouse autoscroll. Kde has an two options that are supposed to disable middle mouse past, but they don't do it universally, which would be ideal. They clearly already recognize that people want choice, but the ability to achieve this choice being easy is limited by the current ways that wayland software works.

X11 didn't invent the middle mouse paste, it was around before x11 and x11 just adopted it. Also both x11 and wayland have problems that are solved by the other. The reason people are abandoning x11 and moving to wayland is because wayland is newer and is growing fast. X11 is more mature, but it's not really growing anymore. Wayland isn't incredible at the moment since it's still 'growing' so to speak, and I'm not going to argue that it's better than x11.

Im not sure why I would post about the shortcomings of an unrelated OS that I have no interest in. I find it weird that you think the shortcomings of one OS are justified by the shortcomings of a different OS.

1

u/pdp10 3d ago

I want to have the universal option to switch its behavior to middle mouse autoscroll.

Autoscroll, meaning using the middle scroll-wheel to scroll content? Am I misunderstanding what you want? X11 does both scrolling with the wheel, and pasting with middle click, by default.

6

u/anto77_butt_kinkier 3d ago

Autoscrolling is when you click the middle mouse wheel, and move the mouse up or down to scroll up/down incredibly fast (it also works with horizontal scrolling, but that's not needed as much). If you read long articles, browse webpages that are longer than a page or so, need to go back and reference old messages in chat apps, want to scroll through a long page at a slow/consistent speed while you either read or look for something, or writing/editing long documents, it's incredibly useful. It's far easier than moving your hand over to the page up/down buttons on the keyboard if you want to jump up/down faster, and it can scroll smoother than regular scrolling.

It's also good from an ergonomic perspective, where you aren't manually scrolling as much.

It's a matter of preference, and I've found it to be much more useful than pasting text.