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 theinput
group.
sudo gpasswd -a $USER input
Notably, you need to replace $USER
with the current user you have logged in on your machine.
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