Skip to content

evuraan/Swipe

Repository files navigation

Swipe

Gestures on Linux.

Swipe

https://evuraan.info/Swipe/

Screengrab:

Features

Swipe uses a novel yet simple correlation mechanism to determine directional intent from event coordinates.

  • Wide range of devices supported
  • Touchscreens - single, double, triple, quad touches supported.
  • Touchpad - double, triple, quad touches
  • Wayland and X11 compatible
  • Easy Installation - download (or git clone) and run.
  • No dependency on Python or Ruby
  • Supports Config files
  • Supports 480+ input events.

Available variants/branches

  • Branch modular - Swipe/1.06e - Use with xdotool or edotool or ydotool or xte etc.

Requirements

  • libinput-tools
      sudo apt-get install libinput-tools 
  • Your user must be a member of input group:
      sudo gpasswd -a $USER input
      newgrp input
  • Optional: Enable touchpad events
      gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled

Setup

  • Download Swipe to a folder. (Either download the latest build from the bin folder, or clone this repo, or download and extract the Zip file.)
      $ wget https://github.com/evuraan/Swipe/blob/main/bin/swipe?raw=true -O swipe 
      $ chmod 775 swipe 
  • Launch swipe. In most cases Swipe will look for and find everything it needs, otherwise you can use the options and/or a config file.

See your distro's documentation to setup Swipe as a Startup Application - an application that starts when a desktop user logs in.

Usage:

$ ./swipe -h
Usage: ./swipe
  -h  --help             print this usage and exit
  -v  --version          print version information and exit
  -s  --sampleCfg        show sample config
  -d  --debug            show verbose output
  -c  /etc/ku.conf       config file to use
  -k  --keys             show available keys
  -i  /dev/input/event1  kbd device to use
  -a  --available        show available devices
  -q  --noIndicator      disable status icon
  • If no config file is specified, Swipe would use a default configuration.
  • If an appropriate kbd device cannot be found, Swipe will ask you to specify a suitable device using the -i option.

Config

Generate a sample config file with -s option. Here are some other config examples.

$ ./swipe -s

Sample Config:
# 2 button touchpad gestures
2right:     "KEY_LEFTALT + KEY_LEFT"
2left:      "KEY_LEFTALT + KEY_RIGHT"

# 3 button touchpad gestures
3right:     "KEY_LEFTALT + KEY_LEFT"
3left:      "KEY_LEFTALT + KEY_RIGHT"
3up:        "KEY_SPACE"
3down:      "KEY_LEFTSHIFT + KEY_SPACE"

# 4 button touchpad gestures
4right:     "KEY_MUTE"
4left:      "KEY_MUTE"
4up:        "KEY_VOLUMEUP"
4down:      "KEY_VOLUMEDOWN"

# Touchscreen gestures
touch1up:   "KEY_UP"
touch1down: "KEY_DOWN"
touch1left: "KEY_LEFTALT + KEY_LEFT"
touch1right:"KEY_LEFTALT + KEY_RIGHT"

touch2up:   "KEY_UP"
touch2down: "KEY_DOWN"
touch2left: "KEY_LEFTALT + KEY_LEFT"
touch2right:"KEY_LEFTALT + KEY_RIGHT"

touch3up:   "KEY_UP"
touch3down: "KEY_DOWN"
touch3left: "KEY_LEFTALT + KEY_LEFT"
touch3right:"KEY_LEFTALT + KEY_RIGHT"

touch4up:   "KEY_UP"
touch4down: "KEY_DOWN"
touch4left: "KEY_LEFTALT + KEY_LEFT"
touch4right:"KEY_LEFTALT + KEY_RIGHT"

Create and edit a custom config to suite your likings:

$ ./swipe -s > mySwipe.conf

Make edits to mySwipe.conf and launch swipe as $ ./swipe -c mySwipe.conf

Config file example

This is config the author currently uses:

# 2 Button Touchpad 
2right: "KEY_LEFTALT + KEY_LEFT"
2left:  "KEY_LEFTALT + KEY_RIGHT"

# 3 Button Touchpad Gestures:
# Zoom in and out
3right: "KEY_LEFTCTRL + KEY_RIGHTSHIFT + KEY_EQUAL" 
3left:  "KEY_RIGHTCTRL + KEY_0"
3up:    "KEY_LEFTCTRL + KEY_RIGHTSHIFT + KEY_EQUAL" 
3down:  "KEY_RIGHTCTRL + KEY_MINUS"

# 4 Button Touchpad Gestures:
# Vol Up/Down/Mute
4right: "KEY_MUTE"
4left:  "KEY_LEFTALT + KEY_RIGHTCTRL + KEY_P"
4up:    "KEY_VOLUMEUP"
4down:  "KEY_VOLUMEDOWN"

# 5 - Touchscreens
touch1up:  "KEY_SPACE"
touch1down: "KEY_RIGHTSHIFT + KEY_SPACE"
touch1left:  "KEY_LEFTALT + KEY_RIGHT"
touch1right:  "KEY_LEFTALT + KEY_LEFT"

touch2up:  "KEY_RIGHTCTRL + KEY_KPPLUS"
touch2down: "KEY_RIGHTCTRL + KEY_MINUS"
touch2left: "KEY_LEFTALT + KEY_RIGHT"
touch2right: "KEY_LEFTALT + KEY_LEFT"

Debug option

Run with -d option to have debug info onto the terminal:

$ ./swipe -d -c /tmp/swipe.conf
Fri Sep 03 19:07:12 2021 Swipe/3.01e Read 14 values from the config file
Fri Sep 03 19:07:12 2021 Swipe/3.01e 2 key touchpad events: map[LEFT:KEY_LEFTALT + KEY_RIGHT RIGHT:KEY_RIGHTALT + KEY_LEFT]
Fri Sep 03 19:07:12 2021 Swipe/3.01e 3 key touchpad events: map[DOWN:KEY_LEFTSHIFT + KEY_SPACE LEFT:KEY_LEFTALT + KEY_RIGHT RIGHT:KEY_LEFTALT + KEY_LEFT UP:KEY_SPACE]
Fri Sep 03 19:07:12 2021 Swipe/3.01e 4 key touchpad events: map[DOWN:KEY_END LEFT:KEY_LEFTALT + KEY_RIGHT RIGHT:KEY_LEFTALT + KEY_LEFT UP:KEY_HOME]
Fri Sep 03 19:07:12 2021 Swipe/3.01e touchscreen events: map[DOWN:KEY_UP + KEY_UP + KEY_UP + KEY_UP + KEY_UP + KEY_UP LEFT:KEY_LEFTALT + KEY_RIGHT RIGHT:KEY_LEFTALT + KEY_LEFT UP:KEY_DOWN + KEY_DOWN + KEY_DOWN + KEY_DOWN + KEY_DOWN + KEY_DOWN]

Desktop notifications (example) are also enabled in debug mode - which shows the details of the event intercepted.

Keys and buttons supported:

Swipe supports about 482 keys/buttons - pretty much inline with Linux's input-event-codes.h.

Run swipe -k to see a full list:

$ ./swipe -k
Available keys:
key -->  KEY_FN_D
key -->  KEY_BRL_DOT8
key -->  KEY_HANJA
key -->  KEY_FILE
key -->  KEY_PHONE
key -->  KEY_ATTENDANT_ON
key -->  KEY_MACRO_PRESET1
key -->  KEY_KP5
key -->  KEY_PAGEUP
key -->  KEY_RIGHT
key -->  KEY_PRESENTATION
key -->  KEY_KBDINPUTASSIST_NEXT
key -->  KEY_FASTREVERSE
key -->  KEY_KP1
<snip>

Optional: Build

If you prefer to build yourself, you will need the Go Programming Language installed on your System.

Go into the folder and build as:

go build