Adding multitouch gesture support to luna
Multitouch gestures are why I prefer a trackpad to a mouse. I’m constantly swiping back and forth between workspaces or swiping to move back a page in a web browser. It really makes moving around on the computer a lot easier. I take it for granted, and when I’m on a computer that doesn’t have gesture support I drive myself crazy attempting to go back in Firefox by swiping my. It’s such an ingrained habit that I do it without even thinking about it, so I try to add gesture support to a system whenever I can.
luna doesn’t come with multi-touch gesture support installed, but it can be added. There are three options: ginn, touchegg and xSwipe. Each is an application that reads your finger movements on the trackpad and translates those movements into keyboard commands. For example, you can set a four finger swipe from right to left to trigger the shortcut super+right. This allows you to change workspaces.
All three options can be installed on luna, but only ginn is available through the software center. Technically touchegg is in the software center too, but that version doesn’t work. If you want to try touchegg then you’ll have to compile it yourself. xSwipe you’ll have to install yourself, but it’s a perl script and doesn’t require any compiling. I’ve installed and configured all three, and while they all do the same thing they do it with varying degrees of success. Below you can read about all three, but if you don’t care about the differences and just want to install something that works then skip to the section on xSwipe.
Ginn
Ginn looks to be the most promising. You can set up several different input types: swipes, pinches, taps and clicks. This means you can have different actions for a three finger swipe and and three finger pinch, tap and click, and you can have a whole different set of actions for four finger and five finger gestures. Plus you can set global gestures and application specific gestures, giving you different gestures in Firefox than you have in Gimp.
That’s a lot of shortcuts built into the trackpad, maybe too many. One downside to ginn is the complexity of the settings file. Its just one giant file with a bunch of code. Its fairly simple to understand, but you could spend hours getting everything just how you want it. Of course you could keep it simple, just set up a couple of gestures, but its still not an easy setup. You have to set sensitivity and if the action should trigger while you’re making the gesture or once you’re done. This is an important decision. I set up a three finger swipe to move back a page in a web browser. That has to be set to act when the gesture is finished. If it does the action while I’m doing the gesture then it will continue to repeat the action till I stop. Instead of going back one page the browser will go back two or three. It’s very inaccurate.
The problem I had with ginn was that triggering an action on finish didn’t work. It read the gesture but never triggered the action. I found a bug report on the issue, so maybe it will be fixed at some point. For now though, it isn’t a good candidate for everyday use. If you want to check it out it can be installed from the Software Center or install via the terminal with the following command.
sudo apt-get install ginn
The configuration file is /etc/ginn/wishes.xml
Touchegg
Touchegg can be compiled following the directions on their site. Functionally it is a lot like ginn, but only triggers actions once. This prevents accidentally going back a half dozen web pages or skipping past the workspace you wanted to switch too. Configuring it is also easier. There is a GUI available here. It does a great job of helping users set up gestures.
The issue with touchegg is it only gave me about a 60%-70% success rate at reading gestures and triggering actions. I found myself repeating gestures quite a bit. It simply wasn’t consistent enough for everyday use, but I only tested it on an Apple Magic Trackpad. Maybe it would have more success on a different trackpad.
xSwipe
That leaves xSwipe. Unfortunately xSwipe is limited compared to ginn or touchegg. It focuses on swiping, vertical or horizontal, and on multi-finger clicks. There is no support for pinching, rotating or tapping, and there are no application specific gestures. You can’t add as many gestures with xSwipe, but the ones you add work. Having more options is great, but having the gestures work consistently is better.
To download and extract xSwipe open the terminal and run the following command.
cd && wget https://github.com/iberianpig/xSwipe/archive/e39800f21c1c33f38c3794d367d657f355296356.zip && unzip e39800f21c1c33f38c3794d367d657f355296356.zip && mv xSwipe-e39800f21c1c33f38c3794d367d657f355296356 xSwipe && rm e39800f21c1c33f38c3794d367d657f355296356.zip
In order for it to work you need to install libx11-guitest-perl
sudo apt-get install libx11-guitest-perl
and you need to enable SHMConfig for your trackpad. If you already have a synaptics conf file then open it up and check your trackpad section for the line:
Option "SHMConfig" "on"
If you have it great. If not add it.
If you don’t already have a conf file create one via the terminal.
sudo mkdir /etc/X11/xorg.conf.d sudo nano /etc/X11/xorg.conf.d/60-synaptics.conf
A blank document will open in the terminal. Paste in the following.
Section "InputClass" Identifier "touchpad" Driver "synaptics" MatchDevicePath "/dev/input/event*" MatchIsTouchpad "on" Option "Protocol" "event" Option "SHMConfig" "on" EndSection
- ctrl+x to close nano
- y to save changes
- enter to verify name/location.
- reboot
You can run xSwipe now by entering this command in terminal.
perl ~/xSwipe/xSwipe.pl
Test out swiping with four fingers or three fingers in your favorite browser. Once you’ve decided its a bit slow to respond or you want to change a gesture to a different action go back to the terminal and hit ctrl + c to quit xSwipe.
Make xSwipe more responsive
- Open xSwipe folder in your home folder.
- Open xSwipe.pl
- Locate “my $baseDist = 0.1;”
- Adjust 0.1 lower to increase xSwipe response time. Mine is set to 0.03
Configuring gestures
Open eventKey.cfg. Look for “’pantheon’=>{“. You’ll see settings for 2, 3, 4, 5 finger swipes and edge swipes. The individual commands look something like this:
right => "LAL/LEF", # alt + left
This means when swiping right xSwipe will execute keyboard codes for alt+left. The “#alt + left” is meaningless. It just interprets the LAL/LEF to human speak. If you want to change the gesture to trigger alt+right then you’d change “LAL/LEF” to “LAL/RIG”. For a complete list of key codes used in xSwipe see here.
I changed my eventKey to:
- 4 finger left and right swipes changes between workspaces
- 4 finger up down and show apps/ show windows
- 3 finger left and right is forward and back in chrome/firefox/midori
- 3 fingers up down show guake/ minimize app (minimize requires keyboard shortcut to be set to super+h. The default command didn’t work on my system, so I just changed it.)
To use these settings open eventKey.cfg and replace the pantheon section with this one:
'pantheon'=>{ swipe2=>{ press => "default", }, swipe3 =>{ right => "LAL/LEF", # alt + left left => "LAL/RIG", # alt + right down => "LSK/h", # supr + h up => "F12", # F12 press => "LAL/F7", # alt + F7 }, swipe4=>{ right => "LSK/LEF", # super + left left => "LSK/RIG", # super + right down => "LSK/a", # super + a up => "LSK/w", # super + w press => "F12", # F12 }, swipe5=>{ right => "LAL/RIG", # alt + right left => "LAL/LEF", # alt + left down => "LCT/LAL/DOW", # ctrl + alt + down up => "LCT/LAL/UP", # ctrl + alt + up press => "LAL/F7", # alt + F7 }, edgeSwipe2=>{ right => "LCT/TAB", # ctrl + tab left => "LSH/LCT/TAB", # shift + ctrl + tab }, edgeSwipe3=>{ down => "LAL/F4", # alt + F4 up => "LCT/LAL/t", # ctrl + alt + t }, edgeSwipe4=>{ down => "LAL/F4", # alt + F4 up => "LCT/LAL/t", # ctrl + alt + t } },
Now for the last thing, hiding the xSwipe folder and launching xSwipe on boot.
- To hide the folder simply rename it to “.xSwipe”.
- To launch on boot open System Settings and go to Startup Applications
- Click Add
- Use xSwipe for the name and comment.
- Use “perl /home/user_name/.xSwipe/xSwipe.pl” for the command.
*Be sure to change “user_name” to your user name.
On your next reboot xSwipe will load in the background. If you use a bluetooth trackpad you’ll want to make sure it activates before you log in. xSwipe doesn’t work if your tackpad connects after xSwipe is launched.
Nice review! Which Trackpads can you recommend for use with Linux?