libinput: Fix your Linux touchpad using libinput

libinput is a modern touchpad driver in Linux. Synaptics-based drivers are not being upgraded to include modern laptops. This article is all about the installation, and configuration of libinput. Here, I will talk about how to set up one, two, and three finger gestures, natural scroll, and scrolling acceleration among other things.

Note: Please note that this article is about X based desktop environment, not Wayland.

Table of contents

Installation of libinput

Debian based distro (Ubuntu, Linux Mint, Mx Linux)

apt-get install xserver-xorg-input-libinput

Arch Linux based distro (Arch Linux, Manjaro, Arco Linux)

pacman -S xf86-input-libinput

Fedora-based distro

yum install libinput

Conflicts with Synaptics

libinput conflicts with Synaptics drivers. If both are installed Synaptics will take precedence due to its higher numeric order 70- in the default installation directory. So either remove Synaptics or give libinput’s configuration file *.conf file a higher number like 100-touchpad.conf.

Configuration of libinput

Create and open the configuration file using your favorite editors:

~$ vim /etc/X11/xorg.conf.d/100-touchpad.conf

By the way, libinput supports many devices – keyboard, touchscreen, tablet, touchpad. Here in this file, you need to create a section for each of your devices. Since you are working on your touchpad, the following section for the touchpad needs to be created:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Now you need to set up basic configuration options for gestures etc:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
    Option "Tapping" "on"
    Option "NaturalScrolling" "true"
    Option "ClickMethod" "clickfinger"
    Option "TappingButtonMap" "lrm"
    Option "AccelSpeed" "0.5"
    Option "DisableWhileTyping" "true"
EndSection

Explanation of above libinput’s option

  • Option "Tapping" "on": single tap means a single left click
  • Option “NaturalScrolling” “true”: natural (reverse) scrolling
  • Option “ClickMethod” “clickfinger”: two-finger click is a context-click (right-click) and a three-finger click is a middle click
  • Option “TappingButtonMap” “lmr”: 1 finger means left mouse button, 2 fingers means middle and 3 fingers mean right-click.
  • Option “TappingButtonMap” “lrm”: 1 finger means left mouse button, 2 fingers means right and 3 fingers mean middle click.
  • Option “AccelSpeed” “0.5”: It is about your pointer’s acceleration. It is a floating number with range [-1,1]
  • Option “DisableWhileTyping” “true”: touchpad disabled while typing; however modifier keys such as Super, and Alt still work.

Other useful libinput options

  • Option "LeftHanded" "bool": for left-handed people; it interchanges left and right buttons.
  • Option "MiddleEmulation" "bool": if bool is set to true, pressing both left and right buttons presses the middle button.

Note: After any changes to the said file restart the x-org server. If you use display managers such as lightdm and sddm, use the following command for restarting the x-org server:

For sddm:

~$ sudo systemctl restart sddm.service

For lightdm:

~$ sudo systemctl restart lightdm.service

Conclusion

That’s all folks. This was all about the basic configuration of the touchpad. Look at the man page to further configure it or if you want to configure your tablet etc.

5 thoughts on “libinput: Fix your Linux touchpad using libinput”

  1. Fernando Silveira

    I’ve tried everything explained here to use libinput with my Lubuntu Lunar Lobster 23.04 in a Lenovo G485, but the touchpad only work booting from the installation usb drive. When booting from the SSD installed OS it doesn’t work.

    1. I have tried it with my Lubuntu setup (on HCL Laptop) and it worked. May be there are some conflicts with other touchpad drivers installed by Lubuntu. So make sure those drivers are disabled/have less precedence.

Leave a Comment

Your email address will not be published. Required fields are marked *