Skip to main content

A modular Python-based gesture recognition tool for Sway/SwayFX

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swaystroke-0.0.2.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swaystroke-0.0.2-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file swaystroke-0.0.2.tar.gz.

File metadata

  • Download URL: swaystroke-0.0.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for swaystroke-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d952bca3b46fd7ff10d7b52312e1185e2712f2f0b2d8b6b56714e867b0f77b62
MD5 72c78f5617aabaf3f4aeae54adfb289e
BLAKE2b-256 a1b80bb88e6c1a0df5544c363828fc9cde8ab05201bf18eab52f3384fed7abdb

See more details on using hashes here.

File details

Details for the file swaystroke-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: swaystroke-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for swaystroke-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0549ba9af1d54caeaa1237bfc2d9d71eeaf2b4a33a63725747aed610a4be6b3
MD5 766e8b6564207acededfa45c92cb3760
BLAKE2b-256 ec73af97dfdf8c7658b75588793d18f91b10b119afbdc2c1a59f73cc2eabb153

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page