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.
You can use the --dump flag to find out what events a devie is creating.
Metadata
Release files for linux-event-triggers 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linux_event_triggers-1.2.0.tar.gz | 9.4 kB | Without provenance | Details for linux_event_triggers-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linux_event_triggers-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for linux_event_triggers-1.2.0-py3-none-any.whl |
Total release size: 19.6 kB
Release files / linux_event_triggers-1.2.0.tar.gz
| Download URL | linux_event_triggers-1.2.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6da3891830225551c580bedcb89f16c4be92146156a9fb347d789aaec7bb713d
|
|
BLAKE2b-256 checksum How to use checksums |
bd455506ae20b9e3e954a9086af785520524f58347dbc736914aa9b609225d63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / linux_event_triggers-1.2.0-py3-none-any.whl
| Download URL | linux_event_triggers-1.2.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60968e13ea9d8856b1d7f89ba377f8fbe40f8c4d80c5c7d5f1c62f0c9536e840
|
|
BLAKE2b-256 checksum How to use checksums |
640097c3ae7ecffc7270f83aef1891e0c18984583aa061da94d578e58c87ccef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for linux-event-triggers 1.2.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.