torsdag den 30. maj 2013

Restoring multi touch gestures in Ubuntu 13.04 64-bit

I was annoyed with the fact that three finger move windows was removed (look here) - it was one of the best options in unity over kde or gnome (imho).

So, the steps below will reenable that gesture (and any other gestures you might need).

This post is based on the steps here:

1) Download the source for current unity:

sudo apt-get build-dep unity
cd /tmp
mkdir unity
cd unity
apt-get source unity
vi unity-7.0.0daily13.04.18~13.04/plugins/unityshell/src/unityshell.cpp

2) Go to line 3287, and comment out the code that intercepts the gestures:

void UnityScreen::InitGesturesSupport()
  std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);
  gestures_sub_launcher_.reset(new nux::GesturesSubscription);

  gestures_sub_dash_.reset(new nux::GesturesSubscription);

  gestures_sub_windows_.reset(new nux::GesturesSubscription);
                                         | nux::DRAG_GESTURE
                                         | nux::PINCH_GESTURE);

3) Compile the unity source (this can take a while):

cd /tmp/unity/unity-*
dpkg-buildpackage -us -uc -nc
cd ..
sudo dpkg -i *deb
sudo apt-get -f install
sudo apt-get autoremove

4) Compile touchegg (and optionally set the MOVE_WINDOW delta - see last in this post):

cd /tmp
sudo apt-get build-dep touchegg
cd touchegg-1.1.1
sudo make install

5) Create touchegg configuration file:

EDIT: If this is the first time you have touchegg installed, create this directory (thanks hpsjoshi+lauchpad):

mkdir -p ~/.config/touchegg

gedit ~/.config/touchegg/touchegg.conf

                <property name="composed_gestures_time">0</property>
        <application name="All">
                <gesture type="PINCH" fingers="3" direction="OUT">
                        <action type="MAXIMIZE_RESTORE_WINDOW"></action>
                <gesture type="TAP" fingers="4" direction="">
                        <action type="SEND_KEYS">Super</action>

                <gesture type="DRAG" fingers="3" direction="ALL">
                        <action type="MOVE_WINDOW"></action>
                <gesture type="PINCH" fingers="3" direction="IN">
                        <action type="MINIMIZE_WINDOW"></action>

EDIT: added more ubuntu gestures (from here)

6) Log out, and log in again. Start 'touchegg' in a terminal to see it that it catches the gestures.

The output looks like this:

[+] New gesture: 
Type      ->  "DRAG" 
Fingers   ->  3 
Direction ->  "LEFT" 
Action    ->  "MOVE_WINDOW" 
App Class ->  "Terra" 
Gesture Start 
Gesture Update 0 "Drag" 
Gesture Update 0 "Drag" 
Gesture Update 0 "Drag" 


A) Optional step for touchegg gesture speed:

I found that the MOVE_WINDOW gesture is very slow (it moves in 0.1 increments when triggered). To fix this, change the delta value here in line 48+49:


            + attrs.value(GEIS_GESTURE_ATTRIBUTE_DELTA_X).toFloat() * 0.1,
            + attrs.value(GEIS_GESTURE_ATTRIBUTE_DELTA_Y).toFloat() * 0.1, 0);

I use 0.8 which works for fine for my touchpad speed:

            + attrs.value(GEIS_GESTURE_ATTRIBUTE_DELTA_X).toFloat() * 0.8,
            + attrs.value(GEIS_GESTURE_ATTRIBUTE_DELTA_Y).toFloat() * 0.8, 0);

After changing this, repeat step 4.

B) Optionally prevent any updates to Unity:

echo "unity hold"|sudo dpkg --set-selections

To revert and allow unity to be installed/updated again, issue this command:

echo "unity install" |sudo dpkg --set-selections 

I have attached my debs here for unity and the compiled touchegg + gui:

touchegg-gce (gui for touchegg)


One last thing is to add an autostart entry for touchegg, this can be done in "Startup Applications", and just add '/usr/bin/touchegg' as command, and give it a name. Touchègg would be a good candidate ;)

The above works great for me on latest Ubuntu 13.04, and i recommend using the touchegg gui, it does an easy job creating new gestures.

And .. no warranties, this is probably not for the average user ;)