Skip to main content

Swaystroke

A modular Python-based gesture recognition tool for Sway/SwayFX (using GTK Layer Shell and i3ipc).

Architecture

  • config.py: Settings like the trigger button.
  • gesture.py: Handles point data and normalization.
  • gui.py: Native GTK3 Layer Shell overlay for drawing gestures.
  • storage.py: Manages saving and loading gestures to gestures.json.
  • recognizer.py: Compares new gestures against stored templates.
  • focus.py: Uses i3ipc to find and focus the correct window under the mouse before executing commands.
  • main.py: Entry point for recording, listening, and debugging.
  • visualizer.py: Imported comparison tool to see gesture matches.

Prerequisites

  • Python 3
  • python-i3ipc, python-gi, python-xlib, pycairo
  • gtk-layer-shell library

Usage

Record a gesture

swaystroke record [--global] [--app-id ID] [--app-class CLASS] [--get-app-id-or-class] <name> [command]

Click and drag to draw your gesture in the transparent overlay. Options:

  • --global: Record the gesture to be available globally.
  • --app-id ID: Bind the gesture to a specific Wayland application ID.
  • --app-class CLASS: Bind the gesture to a specific XWayland window class.
  • --get-app-id-or-class: Automatically get the app ID or class from the window under the gesture.

If no options are provided, it defaults to a global gesture.

Listen for gestures

swaystroke listen

Draw your gesture. The tool will identify the window under your starting point, focus it, and run the command.

List gestures

swaystroke list
swaystroke list-gui

Show all recorded gestures either in an ASCII table or a scrollable graphical window.

Show a specific gesture

swaystroke show "close"

Open the visualizer to display the recorded path for a specific gesture.

Delete a gesture

swaystroke delete "close"

Delete a recorded gesture by its name.

Debug gestures

swaystroke debug

Draw a gesture to see a side-by-side comparison with the closest match.

Generate config

swaystroke generate-config

Generate the default configuration file in the config directory.

Release files for swaystroke 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swaystroke 0.0.2
File Size Uploaded
swaystroke-0.0.2.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swaystroke 0.0.2
File Interpreter ABI Platform
swaystroke-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / swaystroke-0.0.2.tar.gz

Download URL swaystroke-0.0.2.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d952bca3b46fd7ff10d7b52312e1185e2712f2f0b2d8b6b56714e867b0f77b62
BLAKE2b-256 checksum
How to use checksums
a1b80bb88e6c1a0df5544c363828fc9cde8ab05201bf18eab52f3384fed7abdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / swaystroke-0.0.2-py3-none-any.whl

Download URL swaystroke-0.0.2-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0549ba9af1d54caeaa1237bfc2d9d71eeaf2b4a33a63725747aed610a4be6b3
BLAKE2b-256 checksum
How to use checksums
ec73af97dfdf8c7658b75588793d18f91b10b119afbdc2c1a59f73cc2eabb153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page