Multitouch OS X like gestures in Elementary OS

Multitouch OS X like gestures in Elementary OS
Photo by John Smit / Unsplash

One of the many things I love about OS X is multitouch support and gestures associated with it that make my life so much better. When I picked up on GNU/Linux and installed my first dualboot on my MBP a couple of years ago it took me some fiddling and research to make it work the way I wanted to, but the process was relatively pain free and just a matter of pulling a few packages from the Ubuntu repositories as far as I recall.

This is why I was at first a bit disappointed when I picked up a Samsung Ativ Book 9 lite as a second notebook for school. Having no appetite for Windows 8, I made the (very) quick decision to install a decent OS on it. I tried a few distros and I finally settled for Elementary OS, which I think is great and has everything I want plus all the power of Ubuntu under the hood. The installation went by effortlessly (with the exception of the UEFI part of the install, I had trouble booting the live USB in UEFI mode for instance; it wouldn’t load the graphical live session for some reason, but the installation session would run in graphic mode with no problem whatsoever). A couple of updates later, installing the fglrx driver from jockey and saucy kernel (necessary to get wireless working proprerly), and voilà ; everything worked as you would expect it to and I got around 6 hours of battery life, which is more than I ever dreamed of, thanks to the backlight support that for some reason only works with both the newer kernel and the fglrx proprietary driver, and the help of laptop-mode-tools.

The Ativ Book 9 lite has quite a large touchpad and is normally well detected by the computer. However the multitouch gesture implementation is relatively inexistent out of the box, with the exception of two fingers scrolling, which works fine without any issue. But what if you want to be able to use three or four-fingers gestures like on OS X?

Touchegg To the Rescue!

This is where touchégg comes into light. Touchégg is “a multitouch gesture recognizer for GNU/Linux that allows associating actions to each gesture”. My first experience with it was somehow abruptly ended by segmentation faults when using the packaged version that is just an apt-get install touchegg away. I did my research and managed to get it to work fine, using tutorials here and a handy config file from the Elementary OS website, basically building touchégg from source.

Here’s how I got it to work on my machine:

  • Download the touchégg source code from here and unpack it;
  • Download and install dependencies with this handy command: sudo apt-get build-dep touchegg. This will pull and install necessary dependencies.
  • cd to the source directory and run these commands:
  • $ qmake
  • $ make (Note that the make command take a couple of minutes to complete; it’s okay, just look for potential errors in the output. You should be fine.)
  • $ sudo make install
  • Using your favorite text editor, copy the config file from the eOs website and save it under ~/.config/touchegg/touchegg.conf
  • Add touchegg to the list of startup applications, so that it, well, starts up at login.

And voilà ! You’ve got a couple of multitouch gestures that work quite well in an OS X way. For instance, with this config file, a three-fingers swipe to the left or right switches workspaces, up or down switches would show workpsaces or expose open windows respectively, and a four-fingers swipe up resizes the current window.

UPDATE: I made a GitHub repo here: https://github.com/louisduhamel/touchegg-config/. Thanks Robert for the suggestion!

You can also find the file below.

{
<touchégg>
<settings>
<property name=”composed_gestures_time”>111</property>
</settings>
<application name=”All”>
<gesture type=”DRAG” fingers=”1″ direction=”ALL”>
<action type=”DRAG_AND_DROP”>BUTTON=1</action>
</gesture>
<gesture type=”DRAG” fingers=”4″ direction=”DOWN”>
<action type=”SEND_KEYS”>Super+a</action>
</gesture>
<gesture type=”DRAG” fingers=”4″ direction=”UP”>
<action type=”SEND_KEYS”>Super+s</action>
</gesture>
<gesture type=”DRAG” fingers=”4″ direction=”RIGHT”>
<action type=”SEND_KEYS”>Super+Left</action>
</gesture>
<gesture type=”DRAG” fingers=”4″ direction=”LEFT”>
<action type=”SEND_KEYS”>Super+Right</action>
</gesture>
<gesture type=”DRAG” fingers=”3″ direction=”UP”>
<action type=”MAXIMIZE_RESTORE_WINDOW”></action>
</gesture>
<gesture type=”DRAG” fingers=”3″ direction=”DOWN”>
<action type=”MINIMIZE_WINDOW”></action>
</gesture>
<gesture type=”DRAG” fingers=”3″ direction=”RIGHT”>
<action type=”SEND_KEYS”>Control+Super+Right</action>
</gesture>
<gesture type=”DRAG” fingers=”3″ direction=”LEFT”>
<action type=”SEND_KEYS”>Control+Super+Left</action>
</gesture>
<gesture type=”DRAG” fingers=”2″ direction=”ALL”>
<action type=”SCROLL”>SPEED=7:INVERTED=true</action>
</gesture>
<gesture type=”PINCH” fingers=”2″ direction=”IN”>
<action type=”SEND_KEYS”>Control+minus</action>
</gesture>
<gesture type=”PINCH” fingers=”2″ direction=”OUT”>
<action type=”SEND_KEYS”>Control+plus</action>
</gesture>
<gesture type=”TAP” fingers=”3″ direction=””>
<action type=”MOUSE_CLICK”>BUTTON=2</action>
</gesture>
<gesture type=”TAP” fingers=”2″ direction=””>
<action type=”MOUSE_CLICK”>BUTTON=3</action>
</gesture>
<gesture type=”TAP” fingers=”1″ direction=””>
<action type=”MOUSE_CLICK”>BUTTON=1</action>
</gesture>
</application>
Gwenview, Shotwell, Evince”>
<gesture type=”ROTATE” fingers=”2″ direction=”LEFT”>
<action type=”SEND_KEYS”>Control+L</action>
</gesture>
<gesture type=”PINCH” fingers=”2″ direction=”IN”>
<action type=”SEND_KEYS”>Control+KP_Add</action>
</gesture>
<gesture type=”PINCH” fingers=”2″ direction=”OUT”>
<action type=”SEND_KEYS”>Control+KP_Subtract</action>
</gesture>
<gesture type=”ROTATE” fingers=”2″ direction=”RIGHT”>
<action type=”SEND_KEYS”>Control+R</action>
</gesture>
</application>
<application name=”Dolphin, Midori, Chromium-browser, Chrome, Firefox”>
<gesture type=”DRAG” fingers=”5″ direction=”RIGHT”>
<action type=”SEND_KEYS”>Alt+Home</action>
</gesture>
<gesture type=”DRAG” fingers=”5″ direction=”ALL”>
<action type=”SEND_KEYS”>Control+Next</action>
</gesture>
</application>
</touchégg>
}```
<touchégg>
  <settings>
    <property name="composed_gestures_time">111</property>
  </settings>
  <application name="All">
    <gesture type="DRAG" fingers="1" direction="ALL">
      <action type="DRAG_AND_DROP">BUTTON=1</action>
    </gesture>
    <gesture type="DRAG" fingers="4" direction="DOWN">
      <action type="SEND_KEYS">Super+a</action>
    </gesture>
    <gesture type="DRAG" fingers="4" direction="UP">
      <action type="SEND_KEYS">Super+s</action>
    </gesture>
    <gesture type="DRAG" fingers="4" direction="RIGHT">
      <action type="SEND_KEYS">Super+Left</action>
    </gesture>
    <gesture type="DRAG" fingers="4" direction="LEFT">
      <action type="SEND_KEYS">Super+Right</action>
    </gesture>
    <gesture type="DRAG" fingers="3" direction="UP">
      <action type="MAXIMIZE_RESTORE_WINDOW"></action>
    </gesture>
    <gesture type="DRAG" fingers="3" direction="DOWN">
      <action type="MINIMIZE_WINDOW"></action>
    </gesture>
    <gesture type="DRAG" fingers="3" direction="RIGHT">
      <action type="SEND_KEYS">Control+Super+Right</action>
    </gesture>
    <gesture type="DRAG" fingers="3" direction="LEFT">
      <action type="SEND_KEYS">Control+Super+Left</action>
    </gesture>
    <gesture type="DRAG" fingers="2" direction="ALL">
      <action type="SCROLL">SPEED=7:INVERTED=true</action>
    </gesture>
    <gesture type="PINCH" fingers="2" direction="IN">
      <action type="SEND_KEYS">Control+minus</action>
    </gesture>
    <gesture type="PINCH" fingers="2" direction="OUT">
      <action type="SEND_KEYS">Control+plus</action>
    </gesture>
    <gesture type="TAP" fingers="3" direction="">
      <action type="MOUSE_CLICK">BUTTON=2</action>
    </gesture>
    <gesture type="TAP" fingers="2" direction="">
      <action type="MOUSE_CLICK">BUTTON=3</action>
    </gesture>
    <gesture type="TAP" fingers="1" direction="">
      <action type="MOUSE_CLICK">BUTTON=1</action>
    </gesture>
  </application>
  <application name="Gwenview, Shotwell, Evince">
    <gesture type="ROTATE" fingers="2" direction="LEFT">
      <action type="SEND_KEYS">Control+L</action>
    </gesture>
    <gesture type="PINCH" fingers="2" direction="IN">
      <action type="SEND_KEYS">Control+KP_Add</action>
    </gesture>
    <gesture type="PINCH" fingers="2" direction="OUT">
      <action type="SEND_KEYS">Control+KP_Subtract</action>
    </gesture>
    <gesture type="ROTATE" fingers="2" direction="RIGHT">
      <action type="SEND_KEYS">Control+R</action>
    </gesture>
  </application>
  <application name="Dolphin, Midori, Chromium-browser, Chrome, Firefox">
    <gesture type="DRAG" fingers="5" direction="RIGHT">
      <action type="SEND_KEYS">Alt+Home</action>
    </gesture>
    <gesture type="DRAG" fingers="5" direction="ALL">
      <action type="SEND_KEYS">Control+Next</action>
    </gesture>
  </application>
</touchégg>
Mastodon