47

In Windows, I'm used to clicking the center button and it offering a "fast scroll" option up or down. How can I get this behavior on Linux? It currently seems to use the back button upon center click instead.

I use Gnome under CentOS.

some1
  • 1,796
  • What, specifically, doesn't work? Unix mice had three buttons from day one, so the middle mouse button normally works out of the box. – Gilles 'SO- stop being evil' Nov 20 '13 at 22:00
  • I'm used to clicking the center button and it offering a "fast scroll" option up or down. It currently seems to use the back button upon center click instead. – some1 Nov 20 '13 at 22:20
  • 2
    Ah, so you want the Windows behavior of the middle button (or rather of pressing the wheel), instead of the Unix behavior (where the middle button normally pastes the clipboard content). You really need to say this in your question, we can't read your mind! This requires support from applications; which applications do you use? Which desktop environment (e.g. Gnome, KDE, XFCE, …)? – Gilles 'SO- stop being evil' Nov 20 '13 at 22:25
  • 1
    Well, I figured there would be a configuration panel somewhere where I could set that, but I couldn't even get that far. The desktop is Gnome I assume, is that default? And the issue is in firefox. – some1 Nov 20 '13 at 22:27
  • 1
    For Firefox, there's a solution in a near duplicate question. – Gilles 'SO- stop being evil' Nov 20 '13 at 22:43
  • @Gilles - this only allows for scrolling within the Apps Firefox and Chrome, it has nothing to do with general purpose scrolling functionality as the OP is now describing in this revamped version of the Q. – slm Nov 21 '13 at 00:10
  • If using libinput check my answer here. Works with any application without the need of install anything. – Pablo A Feb 03 '18 at 18:38

4 Answers4

40

This Windows feature has never really made its way into the Unix world. In the Unix world, the primary purpose of the middle mouse button is to paste the clipboard content (or more precisely, text selected with the mouse, which is auto-copied). A couple of cross-platform applications such as Firefox and Chrome that support Linux-style middle mouse button under Windows and vice versa, but other than that most applications don't support this kind of fine-grained scrolling.

Nonetheless, you can get fairly close at the system level. It is possible to set up a mouse button such that when it is pressed, mouse movements are transformed into wheel events. This is the same feature that you're used to, but you're likely to find the motion choppy, because applications receive wheel events, which are typically interpreted as scrolling by one whole line or column.

To play with this configuration, use the xinput program (I don't know if there's a GUI frontend for it). First, run the following command to see the name of your pointing device:

$ xinput --list       
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Generic USB Mouse                         id=8    [slave  pointer  (2)]
⎜   ↳ Macintosh mouse button emulation          id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳   USB Keyboard                            id=9    [slave  keyboard (3)]

For example, in the output above, the pointer device is Generic USB mouse. You can run the following command to list the properties that can be tuned:

xinput --list-props 'Generic USB Mouse'

The set of properties you're looking for are the “Evdev Wheel Emulation” ones. With the following settings, when the middle mouse button (button 2) is pressed, moving the mouse sends wheel events (4=up, 5=down, 6=left, 7=right).

xinput --set-prop 'Generic USB Mouse' 'Evdev Wheel Emulation' 1
xinput --set-prop 'Generic USB Mouse' 'Evdev Wheel Emulation Button' 2
xinput --set-prop 'Generic USB Mouse' 'Evdev Wheel Emulation Axes' 6 7 4 5

You may want to tweak other parameters (inertia, timeout).

You can put these commands in a script. Add #!/bin/sh as the very first line, and make the script file executable (e.g. chmod +x ~/bin/activate-wheel-emulation.sh). Then add that script to the list of commands to run when your session starts (gnome-session-properties lets you configure that).

If you have root access and you want to make the change for all users (acceptable on a home machine), it's simpler to do it via the X.org server configuration file. As root, create a file called /etc/X11/xorg.conf.d/wheel-emulation.conf containing settings for the mouse driver. The settings are the same but they're organized a bit differently.

Section "InputClass"
    Identifier "Wheel Emulation"
    MatchProduct "Generic USB Mouse"
    Option "EmulateWheel" "on"
    Option "EmulateWheelButton" "2"
    Option "XAxisMapping" "6 7"
    Option "YAxisMapping" "4 5"
EndSection
  • You will want to exercise caution when tweaking the other parameters. Should you reduce the Evdev Wheel Emulation Timeout parameter too much you may lose the middle mouse button (click) functionality altogether. For example, if you reduce Evdev Wheel Emulation Timeout to below the value for Evdev Middle Button Timeout then you will no longer generate Middle Button Click events. From personal experience, the following seems to work reasonably well: – agnussmcferguss May 12 '15 at 03:55
  • xinput --set-prop 'Generic USB Mouse' 'Evdev Middle Button Emulation' 1. xinput --set-prop 'Generic USB Mouse' 'Evdev Middle Button Timeout' 50. xinput --set-prop 'Generic USB Mouse' 'Evdev Wheel Emulation Timeout' 100. That provides reasonably snappy click and scroll functionality, although if you find it triggers too quickly, then try increasing Evdev Wheel Emulation Timeout (I think 200 is the default) – agnussmcferguss May 12 '15 at 03:55
  • Gilles, I think there's something wrong in your suggested xorg.conf.d configuration file. When I used it my X.Org booted to a black screen. I derived a version which works by adding Device "evdev" and placing double-quotes around the "EmulateWheelButton" value of "2". (Apologies, I haven't time to investigate whether one or both of these changes fixes the problem.) – Arkanon May 30 '15 at 19:27
  • @Arkanon The missing double quotes are definitely a syntax error. I don't think Device "evdev" can make sense, did you mean Driver "evdev"? I think this would be an alternative to the MatchProduct directive which sets the options for all input devices rather than just generic USB mice. – Gilles 'SO- stop being evil' May 30 '15 at 22:01
  • Sorry, I did mean Driver "evdev". Too many hours of looking at man pages. – Arkanon May 31 '15 at 08:55
  • I like that this is done at the X11 level, so that it works no matter which window manager / desktop environment you run – mike Jul 31 '15 at 00:55
  • Is there a way to do this such that when a specific keyboard key is pressed, mouse movements are translated into scroll events? My touchpad only identifies itself as a mouse (it's NOT a driver issue - that's how the manufacturer chose to implement it), so I have only the left/right buttons + movement. – Ponkadoodle Dec 15 '15 at 05:12
  • 1
    @Wallacoloo I don't know if you can get this exact effect, but you can have the numeric keypad move the mouse by typing Pointer_EnableKeys (google it or ask a new question here), and you can set up fancier behavior with XKB (search keybord: mousekeys, or ask a new question here describing exactly what you want and what you'll settle with if you can't have it exactly). – Gilles 'SO- stop being evil' Dec 15 '15 at 09:14
39

Turns out this can be done via Firefox preferences.

  1. From the pull down menu: Edit --> Preferences
  2. Then select the tabs: Advanced --> general
  3. Then check "Use autoscrolling"

Screenshot

   ss

slm
  • 369,824
some1
  • 1,796
4

this works for me, Ubuntu 20.04/20.10: Note, it works everywhere, in every application. How to do this in wayland, I don't know although it is manipulating libinput so it should be possible.

This answer is merely an example of the accepted answer.

#/usr/share/X11/xorg.conf.d/41-libinput.conf
Section "InputClass"
        Identifier "Logitech USB Receiver Mouse"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "ScrollButton" "2"
        Option "ScrollMethod" "button"
        Option "NaturalScrolling" "true"
EndSection
1

for chrome you can use this extension for autoscrolling

AutoScroll

don't forget to restart chrome after installing the extension

codegames
  • 111
  • 3