LIBINPUT-GESTURES
Libinput-gestures is a utility which reads libinput
gestures
from your touchpad and maps them to gestures you configure in a
configuration file. Each gesture can be configured to activate a shell
command which is typically an xdotool command to action
desktop/window/application keyboard combinations and commands. See the
examples in the provided libinput-gestures.conf file. My motivation
for creating this is to use triple swipe up/down to switch workspaces,
and triple swipe right/left to go backwards/forwards in my browser, as
per the default configuration.
This small and simple utility is only intended to be used temporarily until GNOME and other DE's action libinput gestures natively. It parses the output of the libinput list-devices and libinput debug-events utilities so is a little fragile to any version changes in their output format.
This utility is developed and tested on Arch linux using the GNOME 3 DE
on Xorg and Wayland. It works somewhat incompletely on Wayland (via
XWayland). See the WAYLAND section below and the comments in the default
libinput-gestures.conf file. It has been reported to work with
KDE.
I am not sure how well this will work on all distros and DE's etc.
The latest version and documentation is available at
https://github.com/bulletmark/libinput-gestures.
CONFIGURATION
It is helpful to start by reading the documentation about what libinput calls gestures. Many users will be happy with the default configuration in which case you can just type the following and you are ready to go:
libinput-gestures-setup autostart
libinput-gestures-setup start
Otherwise, if you want to create your own custom gestures etc, keep reading ..
The default gestures are in /etc/libinput-gestures.conf. If you want
to create your own custom gestures then copy that file to
~/.config/libinput-gestures.conf and edit it. There are many examples
and options described in that file. The available gestures are:
| Gesture | Example Mapping |
|---|---|
swipe up |
GNOME/KDE/etc move to next workspace |
swipe down |
GNOME/KDE/etc move to prev workspace |
swipe left |
Web browser go forward |
swipe right |
Web browser go back |
swipe left_up |
Jump to next open web browser tab |
swipe left_down |
Jump to previous open web browser tab |
swipe right_up |
Close current web browser tab |
swipe right_down |
Reopen and jump to last closed web browser tab |
pinch in |
GNOME open/close overview |
pinch out |
GNOME open/close overview |
pinch clockwise |
|
pinch anticlockwise |
NOTE: If you don't use "natural" scrolling direction for your touchpad then you may want to swap the default left/right and up/down configurations.
You can choose to specify a specific finger count, typically 3 or more fingers for swipe, and 2 or more for pinch. If a finger count is specified then the command is executed when exactly that number of fingers is used in the gesture. If not specified then the command is executed when that gesture is invoked with any number of fingers. Gestures specified with finger count have priority over the same gesture specified without any finger count.
Of course, 2 finger swipes and taps are already interpreted by your DE and apps for scrolling etc.
IMPORTANT: Test the program. Check for reported errors in your custom gestures, missing packages, etc:
# Ensure the program is stopped
libinput-gestures-setup stop
# Test to print out commands that would be executed:
libinput-gestures -d
(<ctrl-c> to stop)
Confirm that the correct commands are reported for your 3 finger swipe up/down/left/right gestures, and your 2 or 3 finger pinch in/out gestures. Some touchpads can also support 4 finger gestures. If you have problems then follow the TROUBLESHOOTING steps below.
Apart from simple environment variable and ~ substitutions within the
configured command name, libinput-gestures does not run the configured
command under a shell so shell argument substitutions and expansions etc
will not be parsed. This is for efficiency and because most don't need
it. This also means your PATH is not respected of course so you must
specify the full path to any command. If you need something more
complicated, you can add your commands in an executable personal script,
e.g. ~/bin/libinput-gestures.sh e.g. with a #!/bin/sh shebang . Run
that script by hand until you get it working then configure the script
path as your command in your libinput-gestures.conf.
In most cases, libinput-gestures automatically determines your
touchpad device. However, you can specify it in your configuration file
if needed. If you have multiple touchpads you can also specify
libinput-gestures to use all devices. See the notes in the default
libinput-gestures.conf file about the device configuration command.
STARTING AND STOPPING
Search for, and then start, the libinput-gestures app in your DE or
you can start it immediately in the background using the command line
utility:
libinput-gestures-setup start
You can stop the background app with:
libinput-gestures-setup stop
You can enable the app to start automatically in the background when you log in (on an XDG compliant DE such as GNOME and KDE) with:
libinput-gestures-setup autostart
You can disable the app from starting automatically with:
libinput-gestures-setup autostop
You can restart the app or reload the configuration file with:
libinput-gestures-setup restart
You can check the status of the app with:
libinput-gestures-setup status
EXTENDED GESTURES
They are not enabled in the default libinput-gestures.conf
configuration file but you can enable extended gestures which augment
the gestures listed above in CONFIGURATION. See the commented out
examples in libinput-gestures.conf.
swipe right_up(e.g. jump to next open browser tab)swipe left_up(e.g. jump to previous open browser tab)swipe left_down(e.g. close current browser tab)swipe right_down(e.g. reopen and jump to last closed browser tab)pinch clockwisepinch anticlockwise
So instead of just configuring the usual swipe up/down and left/right each at 90 degrees separation, you can add the above extra 4 swipes to give a total of 8 swipe gestures each at 45 degrees separation. It works better than you may expect, at least after some practice. It means you can completely manage browser tabs from your touchpad.





