Skip to main content

Trigger actions based on evdev events from input devices.

Project description

evdev-trigger

Triggers "Actions" on input from evdev- devices. Select which devices to listen to and which actions to trigger based on the input.

PyPI - Version PyPI - Python Version

Demo gif

Table of Contents

Installation

Recommended installation is via pip in a virtual environment:

# Create a virtual environment
python3 -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install evdev-trigger
pip install evdev-trigger

Usage

$ evdev-trigger --help

 Usage: evdev-trigger [OPTIONS]

 Main function

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --file                                        TEXT  Storage file to use for storing reactions [default: storage.json]                                              │
│ --reset-storage         --no-reset-storage          Remove all devices and actions from storage (will not remove actions folder) [default: no-reset-storage]       │
│ --actions                                     TEXT  Folder to load actions from [default: None]                                                                    │
│ --install-completion                                Install completion for the current shell.                                                                      │
│ --show-completion                                   Show completion for the current shell, to copy it or customize the installation.                               │
│ --help                                              Show this message and exit.                                                                                    │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

If you don't provide a storage file using --file, the default storage.json will be used in the current working directory. If --actions is not provided, the default actions folder will be copied to the current working directory, if it doesn't already exist.

Create an action

Examples of a standard action file and a complex action file can be found in the default_actions folder. A action is either a file that contains a class called Action which should use the base class ActionBase or a folder that contains a __init__.py file that contains the same class(es).

The evdev-trigger will call Action.execute with the input_device (Device class from evdev_trigger.models.devices) and the event (InputEvent from evdev.events).

Example of a simple action file:

from evdev_trigger.models import BaseAction


class Action(BaseAction):
    action_name: str = "EXAMPLE_DEBUG_ACTIONS"
    action_description: str = "Prints the device name, event code and value"

    def execute(self, input_device, event):
        """Execute the action"""
        print(f"[EVENT] {input_device.input_device.name}: {event.code} - {event.value}")

License

evdev-trigger is distributed under the terms of the MIT license.

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

evdev_trigger-0.0.2.tar.gz (10.3 MB view details)

Uploaded Source

Built Distribution

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

evdev_trigger-0.0.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: evdev_trigger-0.0.2.tar.gz
  • Upload date:
  • Size: 10.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for evdev_trigger-0.0.2.tar.gz
Algorithm Hash digest
SHA256 557a8b9402da3d1d05e5501a43378f182d3f6006e32b40de1301b107da3abfc3
MD5 c35c88da17d488b61d21ed144fdd48af
BLAKE2b-256 fa98d17439d213c4f37b580368b09156524681446fa36c7464a18f738a342a86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for evdev_trigger-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 655189ae209b203c5f5cc9039bd971363069c47cc00270868ee9971c8fc067ea
MD5 f1590d6b816673239d9720a052b343c1
BLAKE2b-256 3cb0e29769a7192631003d2a101450f5f5f269f8e7bd0a81a6a8364a7559f174

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