70

Clicking the middle button doesn't allow me scroll the page. Is there any way to fix this behavior?

Information:

  1. Ubuntu 10.10
  2. Chromium 9.0.597.94
  3. Logitech MX518

Update: also Chrome, and the other Chromium based ones.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
s7anley
  • 703
  • 1
  • 5
  • 5

5 Answers5

80

In Linux based/Mac systems, Google Chrome / Chromium hasn't got this feature. You have to get an extension, eg.: AutoScroll AutoScroll.

antivirtel
  • 3,635
  • 4
  • 30
  • 46
33

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

Get your input deviceId number

xinput list

To list available properties, use xinput list-props $deviceId. If you are using libinput (the future/present) almost all properties will start with libinput (also check libinput list-devices).

Test: You can always test your input devices with libinput debug-events, xev, evtest, evemu-record or xinput --test $deviceId.

With libinput

Since 17.04 Ubuntu uses libinput, so to set mouse properties:

# xinput device option setting
xinput set-prop $deviceId "libinput Scroll Method Enabled" 0, 0, 1  # _button_ as scroll method
xinput set-prop $deviceId "libinput Button Scrolling Button" 2      # Using middle buttpn. Already 2 by default

xinput set-prop $deviceId "libinput Natural Scrolling Enabled" 1    # OPTIONAL, for natural scrolling. You can also get this with gsettings set org.gnome.desktop.peripherals.mouse natural-scroll true

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 on 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 enable button scrolling the method must be set to button-scrolling and a valid button must be set.

With evdev

xinput --set-prop $deviceId 'Evdev Wheel Emulation' 1
xinput --set-prop $deviceId 'Evdev Wheel Emulation Button' 2
xinput --set-prop $deviceId 'Evdev Wheel Emulation Axes' 6 7 4 5

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
  • Doesn't work for me on Ubuntu 16.04; running the first of the proposed `evdev` commands gives me *"property 'Evdev Wheel Emulation' doesn't exist, you need to specify its type and format"* – Mark Amery Feb 03 '18 at 17:36
  • @markAmery I'm using Ubuntu 16.04 too. Probably you are using libinput. List device properties. Don't forget upvote if it help you. – Pablo Bianchi Feb 03 '18 at 18:17
  • 7
    This is the best answer and should be accepted. – jtolds Mar 10 '18 at 19:00
  • `evdev` worked like a charm. Just to note my mouse device was numbered `10` not `11`. – piepi Mar 12 '18 at 11:45
  • @piepi I edit my answer to be more clear, 11 was just in my case. Don't forget to upvote if you found it useful. – Pablo Bianchi Mar 12 '18 at 18:09
  • This worked gracefully. The next question is, how can I set this script to be run whenever the mouse is plugged in? Otherwise, if the mouse is plugged in *after* the script is run, the changes will not take effect. – Arthur Colombini Gusmão Mar 25 '18 at 22:15
  • @ArthurColombiniGusmão You can create a script [and use udev rules](https://askubuntu.com/a/347971). – Pablo Bianchi Mar 25 '18 at 23:50
  • Thanks @PabloBianchi. I forgot to mention that I already tried it and for some reason the script fails, saying that it wasn't capable of accessing Xserver. Maybe adding some delay to the script can serve as a workaround, but I'm not sure on how to that properly also. – Arthur Colombini Gusmão Mar 26 '18 at 14:44
  • Can't these properties be set in `/usr/share/X11/xorg.conf.d`, so there is no need for a script using udev? – Arthur Colombini Gusmão Mar 26 '18 at 15:22
  • If you want to see values before you start mucking around you can use `xinput list-props ##` where `##` is the device number from `xinput list` – CTS_AE May 02 '19 at 08:30
  • This is great. Thanks @PabloBianchi – Tim Richardson May 25 '19 at 03:01
  • The commands using "Evdev" doesn't work for me on Arch Linux – elig Jul 23 '19 at 07:36
  • after I release the mouse click, the content on clipboard is also pasted. Can I somehow not paste whatever was written on the clipboard when I release the middle button? – Varun Chhangani Apr 17 '20 at 12:35
5

TLDR:

Use this flag on Chrome/Chromium/Electron or anything Chromium-based

--enable-blink-features=MiddleClickAutoscroll

Make sure to close all Chrome instances before running this.

To make this permanent, you can edit the .desktop file and add this flag in the end of the Exec= line (Browsers typically have many Exec= lines for right click actions, the main one is under [Desktop Entry] but you might want to change them all).

For Chrome, the desktop file can be found in this path:
/usr/share/applications/google-chrome.desktop

Explanation:

The code for disabling middle mouse autoscroll on Linux/Mac is here. This basically says if it's running on Windows, enable this blink Runtime Enabled Feature.

According to the Chromium wiki you can use --{enable,disable}-blink-features to enable or disable blink Runtime Enabled Features.

As found here the feature is called MiddleClickAutoscroll so that would be --enable-blink-features=MiddleClickAutoscroll.

The only caviar is this warning message which appears when you use this flag. Other than that it works perfectly on Chrome/-ium, Chromium-based browsers (like Brave) and Electron apps (Discord, Slack, etc).

Notes:

  1. I only tested this on Linux but it might as well work on Mac the same way.
  2. Using the enable-features and blink-enable-features flags is neither recommended nor supported by Chrome/Chromium or whatever you are using. This is why the warning message is displayed, these options are intended for testing use only. If you encounter any bugs after enabling this flag, make sure to disable it before sending a bug report.
  3. It seems there is a reason this is disabled by default (on Linux at least). If you are using Xorg (x11) and you try to use autoscroll while a textbox is selected, it will paste the last selected text to it. A way to fix this is to "disable" the selection clipboard.
Adrian
  • 143
  • 8
1nikolas
  • 51
  • 1
  • 5
  • 1
    Please note that for `--enable-blink-features=MiddleClickAutoscroll` to work you need to close all Chrome instances first. If you are trying this in a new window while you keep this one opened to also try the other answers, it won't work. **CLOSE ALL CHROME INSTANCES BEFORE RUNNING THIS!**. Also worth noting the chrome's executable file can be found at /opt/google/chrome/chrome in Ubuntu, so you would run `/opt/google/chrome/chrome --enable-blink-features=MiddleClickAutoscroll` – Adrian Mar 25 '23 at 18:24
  • 1
    The path of the Chrome's desktop file is `/usr/share/applications/google-chrome.desktop` – Adrian Mar 25 '23 at 18:41
3

I recommend another couple of addons, that allows "Scroll a page as if a scrollbar is under your mouse." I found that give us more control over the scroll move.

With both addons you just click and hold secondary button pressed to scroll pages moving the mouse up and down and even horizontally.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Igor Parra
  • 209
  • 1
  • 5
  • Extensions named as "Scrollbar Anywhere" is working better then "AutoScroll", because it doesn't blocking mouseDown js-event on website'spages if it needn't. – faiwer Jan 20 '17 at 08:58
-1

I have Ubuntu 14.04 and mouse wheel stopped working on one of my Chrome instances. I followed the tip here and it works great. When I go into the page about::flags, the "Smooth Scrolling" option was enabled. I disabled it and it works.

David Foerster
  • 35,754
  • 55
  • 92
  • 145
packetie
  • 135
  • 9