Skip to main content

linux-event-triggers

Execute callbacks such as running commands when a linux event device such as a keyboard or keyboard-emulating device) receives an event. Prevent other processes from receiving the event.

AI-generated and unreviewed.

Motivation

Macroboards and footpedals have a habit of showing up as a keyboard device with fairly standard keys like "a", "b", "c". These conflict with keys that you are already using, for example to insert the character "a", so the entire device must be handled separately. linux-event-triggers is a tool to do this.

Alternatives and prior work

kbd can remap keys for keyboards. It also supports command to run commands. I already used kbd as a separate device and didn't want to mix up another device and activity in this.

triggerhappy basically does the same thing as this program. However, when running in non-daemon mode it does not seem able to grab the event (or so claude says) and I don't really want to mess around with daemons.

You could buy a usb midi device rather than a keyboard emulating device for this purpose. midi tends to make it easier to respond to an event from a single device. The author has written a tool called midi-exec for this purpose, but it mostly a DSL surrounding python libraries.

Installation

pipx install linux-event-triggers

Usage

To print hello when a is pressed on a device, $DEVICE, you can use the following.

evtrig $DEVICE --chown --bind "a=echo hello"

This will attempt to use sudo to chown the device file on initial run, potentially prompting you for a password.

You can use udevadm to find a fixed path for the event device. This will use the USB device name than a name like event17

Once you have this working you will likely want to remove the need for a password in sudo. This can be acheived by editting sudoers to support the specific command you need without a password, or wrangling linuxes udev device registering system to change ownership. I specifically provided a means of working around udev with sudo because udev is too hard to use.

Metadata

Release files for linux-event-triggers 1.1.0

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

Source distribution (sdist)

Source distribution for linux-event-triggers 1.1.0
File Size Uploaded Provenance Actions
linux_event_triggers-1.1.0.tar.gz 7.8 kB Without provenance Details for linux_event_triggers-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linux-event-triggers 1.1.0
File Interpreter ABI Platform Actions
linux_event_triggers-1.1.0-py3-none-any.whl Python 3 none any Details for linux_event_triggers-1.1.0-py3-none-any.whl

Total release size: 16.3 kB

Release files / linux_event_triggers-1.1.0.tar.gz

Download URL linux_event_triggers-1.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd4f1faa25c93c584e7dd845b054d37ae33febe1164d637f2588a79ecc709072
BLAKE2b-256 checksum
How to use checksums
4b9f20ee7d935d28b6638ccd8a3a23a82cc9e70df5fe2f517bd4c621de4db033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / linux_event_triggers-1.1.0-py3-none-any.whl

Download URL linux_event_triggers-1.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfc288f37ce3c23a671db9c5ece576d460cfd94815327b7ae84c615dac701d91
BLAKE2b-256 checksum
How to use checksums
2c4aa0499564c552685b897b715ed24c505f4954e9ddd23451ce10bcf3be3ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for linux-event-triggers 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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