Apple Magic Trackpad gestures on Ubuntu
How I finally got it to work
A Little Preface
When I first heard that Ubuntu added multitouch support a couple years ago, I got really hyped. It was huge. Finally we could have the shiny, cool, but most of all useful feature Apple has always been bragging about on our Linux PCs. So after a bit of research, which showed that multitouch support was there (although it was very basic), I bought a Magic Trackpad for 69 euros. I hoped to follow the development and maybe do some testing.
Big mistake. After the initial hype and announcements, it all became stagnant and half forgotten. After a while I gave up and used the trackpad as a normal one with a couple more features like being wireless and very big.
But today, I tried the in-development version of Ubuntu (14.04) and I thought, why not try the trackpad? Maybe it works now!
Well, no. I got a kernel panic within 2 minutes of each time I was testing it. This is obviously ok, it is still under development after all. Nevertheless, I got interested in the trackpad again and did some research about how to make it work on my elementary OS Luna system, based on Ubuntu 12.04.
I got it to work, and here is how.
First of all, pair the Magic Trackpad, using this guide. Then, create the directory /etc/X11/xorg.conf.d and in it create the file “50-synaptics.conf” with the following content:
Section "InputClass"
Identifier "evdev touchpad catchall"
Driver "synaptics"
MatchUSBID "05ac:030e"
MatchIsTouchpad "on"
Option "Protocol" "event"
Option "SHMConfig" "on"
EndSection
You will need to restart your session after this.
If like me you don’t have two finger scrolling available from the trackpad options in the system settings you have to enable it using xinput:
Use the command
xinput
with no arguments and find the id and the name associated to the trackpad in the list it outputs. On my computer, it was id=12 and the name displayed under “Virtual core pointer” was “Apple Magic Trackpad”, so I will use those. Now, we can use the command
xinput set-prop 12 "Synaptics Two-Finger Scrolling" 1 1
to enable two finger scrolling.
After this we need to get and set up xSwipe. First of all install libx11-guitest-perl with
sudo apt-get install libx11-guitest-perl
Then get xSwipe with
cd ~
wget https://github.com/iberianpig/xSwipe/archive/master.zip
unzip master.zip
cd xSwipe-master
You can then test the default configuration (the eventKey.cfg file) by using the command:
perl xSwipe.pl
To change the default configuration, you can read the official documentation for xSwipe customization. You can also get my configuration file here, which is really simple and has just the basic gestures for desktop and window management.
To start xSwipe as soon as you login automatically we can move the xSwipe.pl and eventKey.cfg files to a folder ~/.xSwipe and then we can create a script to be launched on startup containing
# set your devices names here trackpad="Apple Magic Trackpad"
id=$(xinput | awk -F= "/$trackpad.*pointer/ {print \$2}" | cut -f1)
if [[ -n "${id}" ]]; then xinput set-prop "${id}" "Synaptics Two-Finger Scrolling" 1 1 fi
perl ~/.xSwipe/xSwipe.pl