ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect…

Follow publication

Linux Touchpad Gestures

--

Unlike Windows and Mac, Linux does not support touchpad gestures correctly, and to use some of the built-in gestures of Windows, we may need to do some tricks. Let's get it done!

Photo by Lukas on Unsplash

Installing Dependencies And Necessary Packages

We are going to use a tool called libinput-gesture , but first, we need to install its dependencies.

sudo apt-get install xdotool wmctrl

Now with all the dependencies installed, let's get to installing libinput-gesture itself. We need to head down to its GitHub repo, clone it and install it.

git clone https://github.com/bulletmark/libinput-gestures.git
cd libinput-gestures
sudo make install (or sudo ./libinput-gestures-setup install)

Note: In order to libinput-gesture functions properly, it is essential for us to add our user to the input group.

sudo gpasswd -a $USER input

Notably, you need to replace $USER with the current user you have logged in on your machine.

Photo by davisuko on Unsplash

Configuring libinput-gesture

Simple Configuration

You can find the configuration file on: /etc/libinput-gesture.conf . We can add more gestures to the touchpad by editing the current configuration file. For example, if you are using KDE as your desktop, you can minimize and maximize the opened window by holdingsuper button and pressing one of the page_up/page_down buttons. So we can achieve this for our touchpad like the following:

gesture swipe up        xdotool key super+Page_Up 
gesture swipe down xdotool key super+Page_Down

NOTE: I am using KDE as a desktop, so I am mapping its shortcut keys for the gestures. Please consider mapping keys correctly based on the desktop you are using!

Advanced Configurations (Executing a Bash Script)

It is possible with libinput-gesture to write a bash script and run it on touchpad gestures. First, write down a bash script for changing through the active running application.

touch /home/$USER/scripts/.switchNextApp.sh
chmod + x /home/$USER/scripts/.switchNextApp.sh
vim /home/$USER/scripts/.switchNextApp.sh

Now that the file has been created and the permission has been set, we can write the proper script for switching to the next running application:

#!/bin/sh 

xdotool keydown alt
xdotool key Tab
sleep 0.1
xdotool keyup alt

We can write a switchPrevApp script just like the above:

#!/bin/sh 

xdotool keydown alt
xdotool keydown shift
xdotool key Tab
sleep 0.1
xdotool keyup alt

Now the only thing left is just adding the written scripts to the libinput-gesture configuration file:

gesture swipe left 3    /home/$USER/scripts/.switchNextApp.sh
gesture swipe right 3 /home/$USER/scripts/.switchNextPrev.sh

After everything is done, restart the libinput-gesture service for all the configurations to be applied.

libinput-gestures-setup restart

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

No responses yet

Write a response