75

On Windows, most programs with large, scrollable text containers (e.g. all browsers, most word processors and IDEs) let you press the middle mouse button and then move the mouse to scroll. This scrolling is smooth and allows you to scroll very quickly using just the mouse.

When I've used Linux on laptops, two-finger scrolling performs roughly the same function; it's easy to scroll down a page quickly (much more quickly than one can by scrolling a mouse wheel) but the scrolling remains smooth enough to allow precise positioning.

I am unsure how to achieve the same thing when running Linux on a Desktop with a mouse. As far as I can tell after a whole bunch of Googling, there are neither application-specific settings to swap to Windows-style middle mouse button behaviour, nor any system-wide settings to achieve the same effect.

Just to make this concrete, let's say - if it's relevant - that I'm asking in the context of Firefox, Google Chrome, Gedit and Eclipse on a recent version of either Mint (what I use at home) or Ubuntu (what I use at work). I suspect this is a fairly distro-agnostic and application-agnostic question, though.

As far as I can tell, my options for scrolling are:

  • Scroll with the mousewheel - slow!
  • Use the PgUp / PgDn keys - jumps a huge distance at a time so can't be used for precise positioning, and is less comfortable than using the mouse
  • Drag the scroll bar at the right hand side of the screen up and down like I used to do on old Windows PCs with two-button mice. This is what I do in practice, but it's just plain less comfortable than Windows-style middle-mouse scrolling; on a huge widescreen, it takes me most of a second just to move the cursor over from the middle of the screen to the scrollbar, and most of a second to move it back again, and I have to take my eyes off the content I'm actually scrolling to do this.

None of these satisfy me! This UI issue is the single thing that poisons my enjoyment of Linux on desktops and almost makes me wish I was using a laptop touchpad instead of a mouse. It irritates me enough that I've concluded that either I'm missing some basic Linux UI feature that solves this problem, or I'm just an oversensitive freak and it doesn't even bother anyone else - but I'm not sure which.

So my questions are:

  1. Does Windows-style middle mouse button scrolling exist anywhere in the Linux world, or is it really purely a Windows thing? In particular, do any Linux web browsers let you use Windows-style scrolling?
  2. Are there any mechanisms for scrolling pages that exist in Linux but not in Windows, especially ones that perform the role I've described?
  3. Any other solutions that I'm missing?
6
  • 1
    You call "holding down middle mouse and moving the mouse" "Windows-style" scrolling but I was never aware that there was anything Windows-specific about it. I actually had no idea what you meant by "Windows-style" before I read through your question carefully. You may want to edit your question to use a more enlightening term as I doubt many other people on this site will know what you mean. As far as I can remember that was fairly standard behavior even on Linux - it's probably just a matter of mouse configuration and whether holding down the mouse wheel registers as middle mouse button.
    – jw013
    Dec 19, 2012 at 16:04
  • 2
    @jw013 I've never seen a Linux install where this behavior existed; middle mouse button always seems to just be Paste, and Googling suggests there's no way to turn off the middle-mouse paste behavior (which implies to me no way to turn on middle-mouse scroll behavior - but I'm not sure, which is why I asked here).
    – Mark Amery
    Dec 19, 2012 at 16:07
  • 1
    @jw013 BTW, if you can suggest a more enlightening term I'll use it, but as far as I know this behavior has no proper/official name and I can't think of a succinct and clear name to give it - which is why I described it carefully in my first paragraph instead.
    – Mark Amery
    Dec 19, 2012 at 16:11
  • 1
    I actually switched to a scroll-wheel-less trackball mouse a while ago so all of this is recollection. I'd probably call it "middle mouse scrolling". If I remember correctly, paste only triggered on a simple click, scrolling happened if you held the button down and moved the mouse around. I might have had some settings in my xorg.conf that helped (I tend to copy over my old xorg.conf customizations to new installs so I don't remember exactly). If you are using GNOME try poking around in your mouse preferences and see if there's anything there.
    – jw013
    Dec 19, 2012 at 16:32
  • 1
    @MarkAmery Just in case you didn't already find this, see Gilles' answer to a similar question. The method described by Gilles will enable scroll wheel emulation across all X.Org applications, not just Firefox.
    – Arkanon
    May 31, 2015 at 9:02

5 Answers 5

73

The feature you are talking about is called "Auto-Scrolling". It lets you press and hold the middle mouse button and move your mouse to scroll smoothly. In Linux, the default behavior for this action (pressing middle mouse button) is generally pasting text.

However, there is a preference setting in Firefox and an extension available for Chrome/Chromium which would let you use the middle mouse button for scrolling and activate this feature.

Firefox

  • Open the "Options" tab: "≡" (Open menu) → "Options".

  • Navigate to "General" (it should open to "General" by default).

  • Scroll down to "Browsing".  Under "Browsing", you will find the "Use autoscrolling" option. Put a check mark beside this to activate this functionality in Firefox.

    Or just search for "autoscrolling" using the search bar.

Firefox Preferences tab with autoscrolling highlighted

    In older versions of Firefox: "Edit" → "Preferences" → "Advanced" → "General" → "Browsing" → "User autoscrolling".  Click on the below for a larger image.

        User autoscrolling option in older versions of Firefox

Chrome/Chromium

For Chrome/Chromium we can use an Extension called "AutoScroll" (from kaescripts.blogspot.com).

  • Go to this link on Chrome Web Store (obviously using Chrome/Chromium).

  • Click on the button labeled "+ ADD TO CHROME" to install this extension.

    Chrome Extension

  • Click on "Add" in the Confirmation Dialog Box.

Other Applications

As far as other applications are concerned, I haven't yet found a solution for them. Anyways, it's the tall webpages that create most of the problems for which both Firefox and Chrome/Chromium have a solution.

9
  • 1
    Awesome. I will try out the extensions at work tomorrow and then accept this answer. I'm fairly convinced by now that for most other applications there simply isn't a solution.
    – Mark Amery
    Feb 4, 2013 at 18:32
  • @MarkAmery: Yup... For me this is the most annoying thing in Linux... It still annoys me in one of my folders which contains lots and lots of files... Otherwise, as I said, this feature is mostly useful for webpages, for which we have a solution at hand... :)
    – Aditya
    Feb 4, 2013 at 18:36
  • 2
    It works! Yay! :)
    – Mark Amery
    Feb 5, 2013 at 9:41
  • 1
    On Chrome Web Store and other such special websites extensions are disabled. Jul 31, 2016 at 20:46
  • 2
    This is the better answer and should be accepted: unix.stackexchange.com/a/421672/115227
    – jtolds
    Mar 10, 2018 at 19:01
35

This will work with all your applications without the need of installing anything.

Get your input deviceID. In my case was 11.

xinput list

If you want, list available properties with xinput list-props <deviceID>. If you are using libinput (the future/present), almost all properties will start with libinput. For evdev check my answer here.

With libinput

Set mouse properties

xinput set-prop 11 "libinput Scroll Method Enabled" 0, 0, 1  # This is button
xinput set-prop 11 "libinput Button Scrolling Button" 2      # This is middle mouse. Already 2 by default

Description from man libinput:

  • libinput Scroll Method Enabled 3 boolean values (8 bit, 0 or 1), in order "two-finger", "edge", "button". Indicates which scroll method is currently enabled n this device.
  • libinput Button Scrolling Button 1 32-bit value. Sets the button number to use for button scrolling. This setting is independent of the scroll method, to nable button scrolling the method must be set to button-scrolling and a valid button must be set.

  • You can add this to a shell script and run it at login.
  • Like mouse wheel, with the same movement while pressing Ctrl will zoom in/out page. Ctrl + 0 to reset.
  • This work with X and probably with Wayland.
10
  • "For evdev [do one thing]. With libinput: [do another thing]." How do I know which of those applies to me? I've never heard of either before reading this answer.
    – Mark Amery
    Feb 3, 2018 at 17:28
  • @MarkAmery I don't know a straightforward way, kernel module (modinfo $(lsmod|grep -iE "input" | col1)) doesn't show it. But after you get your deviceID and list properties, if you are using libinput almost all properties will start with that word. Also you will have xserver-xorg-input-libinput package installed, libinput-list-devices command will list your device (certainly on /proc/bus/input/devices). If using X you will find more info diggin on /usr/share/X11/xorg.conf.d/.
    – Pablo A
    Feb 3, 2018 at 18:10
  • 3
    This is the better answer and should be accepted.
    – jtolds
    Mar 10, 2018 at 19:01
  • 2
    I tried this and found that not only it doesn't work in all applications, but also, in those where it does work, it feels very hackish and not Windows-like at all.
    – Marc.2377
    Aug 28, 2019 at 23:42
  • @Marc.2377 Is there a single Linux feature or program that tries to behave like something on Windows that can't be described in that manner? :( Jan 22, 2021 at 12:59
3

TRY THIS : For auto scroll functionality in firefox

firefox > preferences > search auto scroll and enable it

in firefox which comes with vanilla ubuntu its disabled sometimes if you want to further tweak your mouse settings as in the control panel below you might want to install gnome-tweak-tool

sudo apt-get install gnome-tweak-tool enter image description here

SECOND ALTERNATIVE :

  • change the middle mouse button behaviour through xinput.
  • type the below code to probe input devices and peripherals

xinput list

  • and you should get similar display as below: enter image description here
  • now my mouse is 9
  • now write this in terminal

xinput set-prop 9 "libinput Scroll Method Enabled" 0, 0, 1

  • now check the behaviour of mouse when you press the middle key and move up or down in any application with vertical scroll [big text /document].
3
  • 3
    The OP is talking about an issue with all Linux programs,not just Firefox. Jan 9, 2020 at 0:19
  • xinput is working and tested also useful for all Linux programs,not just Firefox. gnome tweak is also useful for all Linux programs,not just Firefox. i updated the answer . Jan 9, 2020 at 4:48
  • Thank you, this works!
    – Player1
    Apr 30, 2020 at 20:47
1

Expanding on Brandon Duffany's answer - his script didn't work on my system (Ubuntu 20.04.3 LTS) and after some debugging, I found it was likely because of the for loop. It behaved as if pointer_ids array was full of empty values and the script just kept returning unable to find device. I figured it was some bash trickery with badly recognized array values so I rewrote the loop.

I made smaller bash script file <path-to-file>/middle-click-emulation.sh:

#!/bin/bash
# Enables middle click to scroll (like Windows).
pointerids=($(xinput list | grep "pointer" | perl -p -e 's@.*?id=(\d+).*@\1@'))

for ((i = 0; i < ${#pointerids[@]}; i++))
do
  echo "Setting up for device id = ${pointerids[$i]}"
  # If the pointer supports scroll method, set middle click to scroll
  if xinput list-props ${pointerids[$i]} | grep 'Scroll Method Enabled' &>/dev/null; then
    xinput set-prop ${pointerids[$i]} 'libinput Scroll Method Enabled' 0 0 1
  fi
done

Manually created the desktop shortcut in ~/.config/autostart/middle_click_to_scroll.sh:

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=Middle click to scroll emulation
Exec="<path-to-file>/middle-click-emulation.sh"
X-GNOME-Autostart-Phase=Initialization
Terminal=false
NoDisplay=true

And gave executable privileges to both the bash script and the desktop shortcut.

And then manually run the script cause I'm too lazy to reboot :-)

Thank you, Brandon :-)

PS: I think you can still use the Brandon's script which creates the desktop shortcuts for you if you replace just the for loop (watch out for the array name).

1
  • I encountered the same 'unable to find device' error code. I also found a workaround and I have a guess what the problem is, and it's not the for loop. I discuss it in my comment reply to his answer. Nonetheless, if I'd seen your comment before trying to fix the problem myself, it probably would have saved me a lot of time. Upvote for helpful answer.
    – mattarod
    Jan 8, 2022 at 17:31
1

Decided to automate Pablo A's answer, since I found it to be the best one (as it works in all apps, not just Firefox).

Save this file as a script (for example: ~/setup_middle_click_scrolling.sh), make it executable with chmod +x, then run it (you can delete it after you run). It enables middle-click to scroll and also adds a startup script so that you get the functionality whenever you log in.

#!/bin/bash
# Enables middle click to scroll (like Windows).
set -e

: ${SCRIPT_PATH:=~/.config/autostart/middle_click_to_scroll.sh}
: ${DESKTOP_PATH:=~/.config/autostart/middle_click_to_scroll.desktop}

# Create dirs if they don't exist.
echo "$SCRIPT_PATH" "$DESKTOP_PATH" | xargs dirname | xargs mkdir -p

# Create a script that can be run on-demand.
# When run, it enables middle-click to scroll.
cat > "$SCRIPT_PATH" << EOF
#!/bin/bash

# Get device IDs of all devices containing "pointer"
pointer_ids=(\$(xinput list | grep pointer | perl -p -e 's@.*?id=(\d+).*@\1@'))

for pointer_id in "\${pointer_ids[@]}"; do
  # If the pointer supports scroll method, set middle click to scroll
  if xinput list-props "\$pointer_id" | grep 'Scroll Method Enabled' &>/dev/null; then
    xinput set-prop "\$pointer_id" 'libinput Scroll Method Enabled' 0 0 1
  fi
done
EOF
chmod +x "$SCRIPT_PATH"

# Create a desktop entry so it runs on startup.
cat > "$DESKTOP_PATH" << EOF
[Desktop Entry]
Type=Application
Name=Middle click to scroll
Exec="$SCRIPT_PATH"
X-GNOME-Autostart-Phase=Initialization
Terminal=false
NoDisplay=true
EOF

"$SCRIPT_PATH"

Hopefully folks in the comments could point out whether this would work on all systems, but it works with my setup of XFCE + libinput + standard 3-button mouse.

3
  • Someone edited my post to change "${pointer_ids[@]}" to "\${pointer_ids[@]}" -- I don't know what shell you're using but that does not work in Bash, so I'm changing the answer back. I'm on bash 5.0.17.
    – Brandon
    Aug 12, 2021 at 23:38
  • 1
    As presented, this script did not work for me. I am not good at shell scripting, so I can't speak with confidence, but, it seems the commands within the middle_click_to_scroll.sh file are being executed at the time the setup_middle_click_scrolling.sh script is run, NOT at the time the middle_click_to_scroll.sh script is run. I don't think this is desired behavior. The person who edited your answer may have been trying to fix that. Personally, I worked around the bug in your script by simply copying the code to the middle_click_to_scroll.sh file manually. Apart from that, this worked! Thanks!
    – mattarod
    Jan 8, 2022 at 17:19
  • 1
    @mattarod you are right, those shell vars inside the cat <<<EOF block were being evaluated when that script was run. I edited it so that it should work now.
    – Brandon
    Feb 20, 2022 at 0:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .