Mac-like touchpad gestures on your Ubuntu 20.04
Mac make it possible for you to perform some gesture using your touchpad to switch between app
One of the special function is the three-finger-swipes which let you switch through your app
What Ubuntu 20.04 does provide is the ability to do these things using keyboard shortcuts! For example the keys (super) will bring up all the open windows with some animation
Let get started
Fusuma is multitouch gesture recognizer written in Ruby. This gem makes your linux PC able to recognize swipes or pinchs and assign commands to them.
Install Fusuma
The first thing you must do is add your user to the input group with the command. Without this fusuma can’t read the touchpad inputs.
sudo gpasswd -a $USER input
Log out, then log back in.
Install some dependencies.
sudo apt-get install libinput-tools
sudo apt-get install xdotool
What we want can also be achieved with just libinput-tools
and xdotool
directly. The only reason we’re using fusuma, is the ease of configuration it provides.
Now install ruby (if not already on your machine), and then fusuma.
sudo apt-get install rubysudo gem install fusuma
Configure Fusuma
Create a config file at this path: ~/.config/fusuma/config.yml
In this file, you can map any touchbar/mouse action to any command/action you want. It can be some keyboard actions, running a command, opening an application etc.
This is my configuration file:
swipe:
3:
left:
command: 'xdotool key alt+Shift+Tab'
right:
command: 'xdotool key alt+Tab'
up:
command: 'xdotool key super+w'
down:
command: 'xdotool key Escape'
pinch:
in:
command: 'xdotool key ctrl+plus'
out:
command: 'xdotool key ctrl+minus'
xdotool is a command line utility we’re taking help of (which we’ already installed above)
xdotool lets you programatically (or manually) simulate keyboard input and mouse activity, move and resize windows, etc
I’ve mapped the three-finger-swipes to keys that help me navigate through open apps. The most helpful is the swipe-up that will bring up all the windows forward.
I also mapped the pinch-in and pinch-out gestures so that I can zoom in and out in most apps easily.
To test if things work, run sudo fusuma
and perform your gestures!
Since you want these gestures to work every time you start the system, you need to add the command fusuma -d
in your Startup Applications, so that it runs every time you start the system.
(If this somehow does not work for you, there is a workaround mentioned here: https://github.com/iberianpig/fusuma/issues/46)
These gestures will not be as smooth as the ones in a Mac, but this will work for most.
Using some other Linux distro?
Fusuma works well with most Linux distros. Just figure out what actions to map to which gestures, and you’re done!