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:
- 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?
- Are there any mechanisms for scrolling pages that exist in Linux but not in Windows, especially ones that perform the role I’ve described?
- Any other solutions that I’m missing?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
- In older versions of Firefox: “Edit” → “Preferences” → “Advanced” → “General” → “Browsing” → “User autoscrolling”.
Click on the below for a larger image.
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.
- 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.
Method 2
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.
Method 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
SECOND ALTERNATIVE :
- change the middle mouse button behaviour through xinput.
- type the below code to probe input devices and peripherals
xinput list
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].
Method 4
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 '[email protected]*?id=(d+).*@[email protected]'))
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).
Method 5
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 '[email protected]*?id=(d+).*@[email protected]'))
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0



