How to customize touchpad gestures on Linux using Fusuma
Tags: linux, ubuntu, ruby
Published: 2019-04-05 17:25:09

---
title: How to customize touchpad gestures on Linux using Fusuma
published: true
description: Fusuma add touchpad gestures to run commands or common tasks, such as changing workspaces, back or forward on a browser, etc.
tags: Linux, Ubuntu, Ruby
cover_image: https://thepracticaldev.s3.amazonaws.com/i/71n21w2n1nfdoieku5he.jpg
---

I published "Fusuma" to RubyGems that recognize swipe or pinch gesture on Linux touchpad.
https://github.com/iberianpig/fusuma

You can add touchpad gestures to run commands or common tasks, such as changing workspaces, back or forward on a browser, etc.

This my first post is how to use and customize Fusuma.

# Install Fusuma

If you use Debian-based OS (using apt for package management), you can use the following commands like "apt install" as they are.

I'm using fusuma on elementary OS Loki on Dell XPS 13(9360).

You can use libinput that depends on Fusuma for Ubuntu 15.04 and above, but you should try xswipe to use the Synaptics driver for older versions' Ubuntu.

## Confirm installed Ruby version

Please confirm at first whether you have ruby installed.

You can use the fusuma with Ruby it installed in System Wide.

(Of course, even rbenv and rvm is OK)

```
$ ruby -v

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
# confirm the version of ruby installed
```

## Install dependent packages

Install `libinput-tools` for reading touchpad input.

(Fusuma use the output of debug logs by `libinput debug-events` in itself)

```shell
$ sudo apt install libinput-tools
```

Also install `xdotool` so that fusuma trigger shortcuts such as `Alt + Left`, `Alt + Right` and so on.

```shell
$ sudo apt install xdotool
```

## Install Fusuma From RubyGems

```shell
$ sudo gem i fusuma
```

`i` is an abbreviation for `install`. If you want to install the fusuma to Ruby in System-Wide is required `sudo`.

(If you use the Ruby you have installed via rbenv and rvm, you can install with `$ gem install fusuma`)

## Create configurations file for Fusuma

Create a configurations file to `~/.config/fusuma/config.yml`

```shell
$ mkdir -p ~/.config/fusuma
$ touch ~/.config/fusuma/config.yml
```

Open `~/.config/fusuma/config.yml` in editor, then paste following content.
```yaml
swipe:
  3:
    left:
      command: 'xdotool key alt+Right'
    right:
      command: 'xdotool key alt+Left'
    up:
      command: 'xdotool key ctrl+t'
    down:
      command: 'xdotool key ctrl+w'
```

The above example is registering the shortcut of the browser by three fingers' swipe.
(Back / Forward / Create Tab / Close Tab)

## Add the user to input groups

To execute Fusuma, it needs to give permission to read to the input of touchpad to the user.

```
$ sudo gpasswd -a $USER input
```

`gpasswd` command adds the user to the input group.
(`$ USER` is the username at runtime)

**Need to log out and log in (or restart) from X**

Fusuma cannot recognize the touchpad without this process.
Because it must be reflected to add the user in the input group.

# Launch Fusuma

Open terminal, and type Fusuma and endter.

```shell
$ fusuma
```

It's OK if all actions are worked (Back / Forward / Create Tab / Close Tab)  when you swipe with Three-finger on the browser.


## Keep running in the background when the terminal is closed

```shell
$ fusuma -d
```

This `-d` option is running as Unix demon, it disconnects from the terminal process.
So `fusuma` is available even after closing terminal.

# Configure commands to be assigned gesture
Add recognition gestures and assigns commands to it in `~/.config/fusuma/config.yml`.

## Confirm command to run in terminal

To switch the workspace, you can set `xdotool key ctrl + alt + Up` or` xdotool key ctrl + alt + Down` 
I recommend that you try such commands to work properly on the terminal. 

Shortcuts for workspace depend on the WindowManager in this example. (Gnome 3 moves up and down with `xdotool key ctrl + alt + Up` and` xdotool key ctrl + alt + Down`)


## Switch the workspace in the four fingers' swipe
Paste the following at the bottom of the `swipe` section

```yml
  4:
    up: 
      command: 'xdotool key ctrl+alt+Down'
    down: 
      command: 'xdotool key ctrl+alt+Up'
```

If you rewrite the config file, you must do re-run `fusuma` command after it stops with `Ctrl-c` or `kill` command.

If you can confirm the operation of the customized four-finger swipe, it is OK.


# Autostart setting of Fusuma

Set fusuma to start automatically, because it is troublesome to open the terminal and execute Fusuma command with every restarts your laptop.

1. Enter the `which fusuma` in the terminal, to note the path to launch Fusuma

2. Start `gnome-session-properties`, enter the launch path noted the previous step by adding the `-d` options (daemonize) at the end.

# Update Fusuma

```shell
$ sudo gem update fusuma
```

(If you have installed fusuma with Ruby on rbenv or rvm, you can update with `$ gem update fusuma`)

# Other customizations

In `~/.config/fusuma/config.yml`, you can set Pinch Zoom (`pinch in` / `pinch out`) and Sensitivity for each gesture(`threshold`).
It is also possible to set gestures that pinch in continuity.

See [Fusuma repository README](https://github.com/iberianpig/fusuma/blob/master/README.md) for more information.

# When finding a bug

If you find any bug or issue, please register the issue to [Github Issue](https://github.com/iberianpig/fusuma/issues).

# Donation
Do you want to support Fusuma? Check out the fully optional donation option, a way to support Fusuma's ongoing development directly: https://github.com/sponsors/iberianpig