DEV Community

Cover image for Configure application-specific gestures with Fusuma v2!

Configure application-specific gestures with Fusuma v2!

Kohei Yamada
Freelance engineer working in Japan🗾 I specialize in developing software with Ruby. I can build applications with Ruby on Rails or SPA using the front-end frameworks.
・2 min read

Starting from this article, I will explain how to configure the new features available in Fusuma v2.
If you haven't updated to Fusuma v2, please refer to the previous article.

So far, Fusuma has only allowed you to set one type of action for a gesture globally.
However, by using the context of Fusuma v2, you will be able to switch Config dynamically.

In this article, we will install fusuma-plugin-appmatcher and configure application-specific settings on Fusuma's config.yml.

Install fusuma-plugin-appmatcher

Run the following command in a terminal

$ sudo gem install fusuma-plugin-appmatcher
Enter fullscreen mode Exit fullscreen mode

How to configure fusuma-plugin-appmather

Get the application name to use in the configuration.

To get application name (WM_CLASS) to specify in config.yml, use $ fusuma-appmatcher -l.
Without -l option, only foreground application names are retrieved.

$ fusuma-appmatcher -l
Enter fullscreen mode Exit fullscreen mode

Set context: WM_CLASS in config.yml.

To add to the existing config.yml.

  1. add --- to the bottom of ~/.config/fusuma/config.yml to separate context.
  2. add context: { application: Google-chrome }.
  3. add swipe: ... ... and describe the gestures as usual.

In the following example, 4-finger gesture is the default setting, and 3-finger swipe gesture is assigned with different behaviors for Google Chrome and Gnome Terminal.

This example uses fusuma-plugin-wmctrl , fusuma-plugin-sendkey and fusuma-plugin-keypress .

When I try swiping up three fingers on Google Chrome and Gnome Terminal respectively, both tabs open.
I was able to assign different keys to them: LEFTCTRL+T for Google Chrome and LEFTSHIFT+LEFTCTRL+T for Gnome Terminal.

Concept of Context in Fusuma v2

Actually, Fusuma runs as an event-driven application.

When a user touches the trackpad, some touch events will be sent to Fusuma. Fusuma will calculate the events and if they exceed the threshold, it will pass them to the executor plugin as swipe events and execute the action associated with the event content from config.yml.

Fusuma will search the config.yml for actions that match the event, but when a context event is issued, Fusuma will search the config for actions that match that context.

  • Fusuma v2 can accept YAML documents containing ---.
  • You can create a context by separating the config.yml with three --- hyphens.
  • The first document delimited by --- is treated as the default configuration.
  • By the way, --- is a standard YAML syntax that allows multiple documents to be described in one file.

Under context: is the event-name of the context and its value.

  event-name: value

      sendkey: 'LEFTALT+RIGHT'
Enter fullscreen mode Exit fullscreen mode

Currently, context events can only be fired by the fusuma-plugin-appmatcher plugin.

In the future, we plan to support context events from tail or external commands by generalizing the events.
For example, a user can define a config that is valid only when a specific device is connected.

Discussion (0)