touchegg

Linux multi-touch gesture recognizer

Github星跟踪图

Follow Touchégg on... Twitter

Touchégg

Touchégg is an app that runs in the background and transform the gestures you make on your touchpad
into visible actions in your desktop.

For example, you can swipe up with 3 fingers to maximize a window or swipe left with 4 finger to
switch to the next desktop.

Many more actions and gestures are available and everything is easily configurable.

Demo

Table of contents

Installation

On the releases page you will find a package
for your distribution.

Otherwise you can compile the source code yourself by following the instructions available in the
HACKING.md file.

Ubuntu, Debian and derivatives

Download the .deb package and install it. Double click on the package may work, otherwise install
it from the terminal:

$ cd ~/Downloads # Or to the path where the deb package is placed at
$ sudo dpkg -i touchegg_*.deb # Install the package
$ sudo apt -f install # Install missing dependencies
$ touchegg # Run Touchégg

Red Hat, Fedora, CentOS and derivatives

Download the .rpm package and install it. Double click on the package may work, otherwise install
it from the terminal:

$ cd ~/Downloads # Or to the path where the rpm package is placed at
$ sudo yum localinstall touchegg-*.rpm # Install the package

Arch Linux, Manjaro and derivatives

Install the touchegg package from AUR.

Add Touchégg to Startup Applications

Depending on your desktop environment, this step is different
You can easily add Touchégg to your startup applications following this steps:

  • Gnome: Add
    /usr/bin/touchegg as command
  • KDE: Add
    /usr/bin/touchegg as script symlink
  • elementary OS: Open System Settings
    -> Applications -> Startup -> Add custom command -> /usr/bin/touchegg

Configuration

After installing Touchégg you'll notice that you can start using multi-touch
gestures. However, you are not forced to use the gestures and actions that come out of the box, you
can configure the gestures you'd like to use and the actions they'll trigger.

Your configuration file is placed in ~/.config/touchegg/touchegg.conf, open it with your favorite
text editor. It is a XML document with 3 main sections:

  • Global settings
  • Global gestures: <application name="All">...</application>
  • Application specified gestures: <application name="Google-chrome,Firefox"></application>

Find more information in the sections below.

Global settings, Option, Value, Default, Description, Example, -, -, -, -, -, animation_delay, Number, 150, Delay, in milliseconds, since the gesture starts before the animation is displayed, Use the MAXIMIZE_RESTORE_WINDOW action. You will notice that no animation is displayed if you complete the action quick enough. This property configures that time, action_execute_threshold, Number, 20, Percentage of the animation to be completed to apply the action, Use the MAXIMIZE_RESTORE_WINDOW action. You will notice that, even if the animation is displayed, the action is not executed if you did not moved your fingers far enough. This property configures the percentage of the animation that must be reached to execute the action, color, Hex color, 3E9FED, Color of the animation, #909090, borderColor, Hex color, 3E9FED, Color of the animation, FFFFFF

Available gestures

Swipe

From libinput documentation:
Swipe gestures are executed when three or more fingers are moved synchronously in the same
direction.

Note that three is the minimum number of fingers that Touchégg allows for swipe gestures.

Example:

<gesture type="SWIPE" fingers="3" direction="UP">
  <action type="MAXIMIZE_RESTORE_WINDOW">
    <animate>true</animate>
  </action>
</gesture>

Pinch

From libinput documentation:
Pinch gestures are executed when two or more fingers are located on the touchpad and are either
changing the relative distance to each other (pinching) or are changing the relative angle (rotate).

Example:

<gesture type="PINCH" fingers="4" direction="IN">
  <action type="CLOSE_WINDOW">
    <animate>true</animate>
    <color>F84A53</color>
    <borderColor>F84A53</borderColor>
  </action>
</gesture>

Available actions

Maximize or restore a window (MAXIMIZE_RESTORE_WINDOW)

Maximize the window under the pointer. If it is already maximized, restore it.

Options:, Option, Value, Description, -, -, -, animate, true/false, Set it to true to display the animation. false otherwise., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="SWIPE" fingers="3" direction="UP">
  <action type="MAXIMIZE_RESTORE_WINDOW">
    <animate>true</animate>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

Animation

Minimize a window (MINIMIZE_WINDOW)

Minimize the window under the pointer.

Options:, Option, Value, Description, -, -, -, animate, true/false, Set it to true to display the animation. false otherwise., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="SWIPE" fingers="3" direction="DOWN">
  <action type="MINIMIZE_WINDOW">
    <animate>true</animate>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

Animation

Tile/snap a widow (TILE_WINDOW)

Resize and move the window under the pointer to use half of the screen.

Options:, Option, Value, Description, -, -, -, direction, left/right, Use the left or right half of the screen, animate, true/false, Set it to true to display the animation. false otherwise., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="SWIPE" fingers="3" direction="LEFT">
  <action type="TILE_WINDOW">
    <direction>right</direction>
    <animate>true</animate>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

<gesture type="SWIPE" fingers="3" direction="RIGHT">
  <action type="TILE_WINDOW">
    <direction>left</direction>
    <animate>true</animate>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

Animation

Close a window (CLOSE_WINDOW)

Close the window under the pointer.

Options:, Option, Value, Description, -, -, -, animate, true/false, Set it to true to display the animation. false otherwise., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="PINCH" fingers="4" direction="IN">
  <action type="CLOSE_WINDOW">
    <animate>true</animate>
    <color>F84A53</color>
    <borderColor>F84A53</borderColor>
  </action>
</gesture>

Animation

Switch desktops/workspaces (CHANGE_DESKTOP)

Change to another desktop/workspace.

Options:, Option, Value, Description, -, -, -, direction, previous/next/up/down/left/right, The desktop/workspace to switch to. It is recommended to use previous/next for better compatibility. However, some desktop environments, like KDE, allow to configure a grid of desktops and up/down/left/right come in handy., animate, true/false, Set it to true to display the animation. false otherwise., animationPosition, up/down/left/right, Edge of the screen where the animation will be displayed., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="SWIPE" fingers="4" direction="LEFT">
  <action type="CHANGE_DESKTOP">
    <direction>next</direction>
    <animate>true</animate>
    <animationPosition>right</animationPosition>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

<gesture type="SWIPE" fingers="4" direction="RIGHT">
  <action type="CHANGE_DESKTOP">
    <direction>previous</direction>
    <animate>true</animate>
    <animationPosition>left</animationPosition>
    <color>3E9FED</color>
    <borderColor>3E9FED</borderColor>
  </action>
</gesture>

Animation

Show desktop (SHOW_DESKTOP)

Show the desktop. If the desktop is already being shown, restore all the windows.

Options:, Option, Value, Description, -, -, -, animate, true/false, Set it to true to display the animation. false otherwise., color, Hex color, Color of the animation. For example: 909090, borderColor, Hex color, Border color of the animation. For example: #FFFFFF, Example:

<gesture type="SWIPE" fingers="4" direction="DOWN">
  <action type="SHOW_DESKTOP">
    <animate>true</animate>
    <color>909090</color>
    <borderColor>FFFFFF</borderColor>
  </action>
</gesture>

Animation

Keyboard shortcut (SEND_KEYS)

Emulate a keyboard shortcut.

Options:, Option, Value, Description, -, -, -, repeat, true/false, Whether to execute the keyboard shortcut multiple times (default: false). This is useful to perform actions like pinch to zoom., modifiers, Keycode, Typical values are: Shift_L, Control_L, Alt_L, Alt_R, Meta_L, Super_L, Hyper_L. You can use multiple keycodes: Control_L+Alt_L.See "Keycodes" below for more information., keys, Keycode, Shortcut keys. You can use multiple keycodes: A+B+C. See "Keycodes" below for more information., on, begin/end, Only used when repeat is false. Whether to execute the shortcut at the beginning or at the end of the gesture., decreaseKeys, Keycode, Only used when repeat is true. Keys to press when you change the gesture direction to the opposite. You can use multiple keycodes: A+B+C. This is useful to perform actions like pinch to zoom, check Example 2 below., Keycodes:

For a full list of key codes, open /usr/include/X11/keysymdef.h with your favorite text editor.

It is important to remove the XK_ prefix. For example, the super keycode is defined as
XK_Super_L but it must be used as Super_L in the configuration.

Example 1: Pinch to zoom example

<gesture type="PINCH" fingers="2" direction="IN">
  <action type="SEND_KEYS">
    <repeat>true</repeat>
    <modifiers>Control_L</modifiers>
    <keys>KP_Subtract</keys>
    <decreaseKeys>KP_Add</decreaseKeys>
  </action>
</gesture>

<gesture type="PINCH" fingers="2" direction="OUT">
  <action type="SEND_KEYS">
    <repeat>true</repeat>
    <modifiers>Control_L</modifiers>
    <keys>KP_Add</keys>
    <decreaseKeys>KP_Subtract</decreaseKeys>
  </action>
    </gesture>

Example 2: Open Gnome application launcher

<gesture type="PINCH" fingers="4" direction="IN">
  <action type="SEND_KEYS">
    <repeat>false</repeat>
    <modifiers>Super_L</modifiers>
    <keys>A</keys>
    <on>begin</on>
  </action>
</gesture>
</application>

Animation

Execute a command (RUN_COMMAND)

Run any command.

Options:, Option, Value, Description, -, -, -, repeat, true/false, true if the command should be executed multiple times. false otherwise., command, Command, The command to execute., on, begin/end, Only used when repeat is false. If the command should be executed on the beginning or on the end of the gesture., decreaseCommand, Keycode, Only used when repeat is true. Command to run when you change the gesture direction to the opposite. Check Example 2 below., Example 1:

<gesture type="SWIPE" fingers="4" direction="DOWN">
  <action type="RUN_COMMAND">
    <repeat>false</repeat>
    <command>notify-send 'Hello' 'World'</command>
    <on>begin</on>
  </action>
</gesture>

Example 2:

<gesture type="SWIPE" fingers="4" direction="DOWN">
  <action type="RUN_COMMAND">
    <repeat>true</repeat>
    <command>notify-send 'Swipe direction' 'DOWN'</command>
    <decreaseCommand>notify-send 'Swipe direction' 'UP'</decreaseCommand>
  </action>
</gesture>

Daemon configuration

This is an advanced topic and my recommendation is to ignore it.

Touchégg runs in two different processes, one of them is a systemd daemon configured in
/lib/systemd/system/touchegg.service. In addition to the --daemon argument, you can pass two optional arguments:, Option, Value, Default, Description, Example, -, -, -, -, -, threshold, Number, Calculated automatically according to your device characteristics, Amount of motion to be made on the touchpad before a gesture is started, Put 3 fingers on your touchpad. You will notice that the action does not start until you move them a little bit. This property configures how much you should move your fingers before the action starts, animation_finish_threshold, Number, Calculated automatically according to your device characteristics, Amount of motion to be made on the touchpad to reach the 100% of an animation, Use the MAXIMIZE_RESTORE_WINDOW action. You will notice that you need to move your fingers a certain ammount until the animation fills your entire screen. This property configures how much you need to move your fingers, It is recommended NOT to configure threshold and animation_finish_threshold since an optimal
value is calculated for you. This value is printed to the terminal on application startup or when a
new multi-touch device is connected.

Example:

$ cat /lib/systemd/system/touchegg.service, grep ExecStart
ExecStart=/usr/bin/touchegg --daemon 100 500

$ sudo systemctl daemon-reload && sudo systemctl restart touchegg

$ journalctl -u touchegg -b -f
Compatible device detected:
  Name: Apple Inc. Magic Trackpad 2
  Size: 161.957mm x 115.114mm
  Calculating threshold and animation_finish_threshold. You can tune this values in your service file
  threshold: 100
  animation_finish_threshold: 500

Copyright

Copyright 2011 - 2020 José Expósito <jose.exposito89@gmail.com>

The source code is available under GPL v3 license on GitHub

主要指标

概览
名称与所有者JoseExposito/touchegg
主编程语言C++
编程语言C++ (语言数: 5)
平台
许可证GNU General Public License v3.0
所有者活动
创建于2015-03-16 16:09:19
推送于2025-06-14 16:36:45
最后一次提交2025-06-14 18:28:28
发布数20
最新版本名称2.0.18 (发布于 )
第一版名称1.1.1 (发布于 )
用户参与
星数3.9k
关注者数52
派生数174
提交数673
已启用问题?
问题数618
打开的问题数28
拉请求数52
打开的拉请求数4
关闭的拉请求数14
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?