Enable Natural Scrolling for Trackpads Using libinput

Libinput is a library to handle input devices in Wayland and X.Org. It can be used as a drop-in replacement for evdev and synaptics in X.Org, and it is supported by a wide range of desktop environments, including GNOME and Xfce. In this post, we will see how to enable natural scrolling for trackpads using libinput. We will also leave mouses alone, i.e., no natural scrolling for mouses.

First, we need to know the name of the trackpad to enable natural scrolling for. This can be easily known by executing xinput --list. My output includes the following:

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ bcm5974                                   id=13   [slave  pointer  (2)]

It is easy to see that my trackpad is bcm5974.

Then, we need to know whether libinput is in charge of the trackpad. This can be done by executing xinput --list-props bcm5974 (replace bcm5974 with your device) and looking for the prefix libinput there. In my case, the output includes the following:

Device 'bcm5974':
        Device Enabled (145):   1
        Coordinate Transformation Matrix (147): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        libinput Tapping Enabled (340): 0
        libinput Tapping Enabled Default (341): 0
        libinput Tapping Drag Enabled (342):    1
        libinput Tapping Drag Enabled Default (343):    1
        libinput Tapping Drag Lock Enabled (344):       0
        libinput Tapping Drag Lock Enabled Default (345):       0
        libinput Tapping Button Mapping Enabled (346):  1, 0
        libinput Tapping Button Mapping Default (347):  1, 0
        libinput Accel Speed (348):     0.000000
        libinput Accel Speed Default (349):     0.000000
        libinput Natural Scrolling Enabled (350):       1
        libinput Natural Scrolling Enabled Default (351):       0
        libinput Send Events Modes Available (265):     1, 1
        libinput Send Events Mode Enabled (266):        0, 0
        libinput Send Events Mode Enabled Default (267):        0, 0
        libinput Left Handed Enabled (352):     0
        libinput Left Handed Enabled Default (353):     0
        libinput Scroll Methods Available (354):        1, 1, 0
        libinput Scroll Method Enabled (355):   1, 0, 0
        libinput Scroll Method Enabled Default (356):   1, 0, 0
        libinput Click Methods Available (357): 1, 1
        libinput Click Method Enabled (358):    0, 1
        libinput Click Method Enabled Default (359):    0, 1
        libinput Middle Emulation Enabled (360):        0
        libinput Middle Emulation Enabled Default (361):        0
        libinput Disable While Typing Enabled (362):    1
        libinput Disable While Typing Enabled Default (363):    1
        Device Node (268):      "/dev/input/event13"
        Device Product ID (269):        1452, 610
        libinput Drag Lock Buttons (364):       
        libinput Horizontal Scroll Enabled (365):       1

That means libinput is in charge of my trackpad.

Now we can enable natural scrolling for this trackpad. To do this manually, use the following command (remember to replace bcm5974 with your device name):

xinput --set-prop bcm5974 "libinput Natural Scrolling Enabled" 1

We can always add this into ~/.xsessionrc to make it automatically take effect upon logging in.

3 thoughts on “Enable Natural Scrolling for Trackpads Using libinput

  1. Pingback: Links 27/2/2017: GNU Linux-libre 4.10, Weston 2.0.0, Git 2.12.0, Linux From Scratch 8.0 | Techrights

  2. whot

    Hi, libinput maintainer here.

    xinput set-prop “bcm5974” “libinput Natural Scrolling Enabled” 1

    saves you having to figure out the device ID. Also, *never* supply format and type to xinput set-prop unless you want to create a new property. If you leave it out, xinput will do the right thing but, more importantly, it’ll complain if the property doesn’t exist. With your command, you create the property if it doesn’t exist (e.g. if the synaptics driver is active) and nothing will happen.

    Finally. libinput-list-devices doesn’t tell you whether the xf86-input-libinput xorg driver is active, only whether libinput would detect the device. To figure out whether the xf86-input-libinput driver is running, run xinput list-props “bcm5974” and check for a “libinput” prefix on the properties.

    Reply

Leave a Reply

Your email address will not be published.