Monitor udev events like usb devices being connected, and execute actions upon evnet
Project description
udev_monitor
Monitor linux udev events and execute actions on detection
Designed to execute actions when USB devices are plugged-in / removed
udev_monitor works with Linux udev and monitors it's events. Upon a specific event for a given device, it will execute an action.
Setup:
pip install udev_monitor
Example:
Run script /usr/local/bin/myscript.sh
everytime USB device 0665:5161 is added or removed
udev_monitor.py --devices 0665:5161 --udev-actions add,remove --filters=usb --action /usr/local/bin/restart_nut_driver.sh
Full usage:
--devices List of comma separated devices to monitor. Example:
'0665:5161, 8086:1234'
--udev-actions List of udev events which should trigger and action
Valid actions are: 'add', 'remove', 'change', 'online', 'offline'. Defaults to 'add, change, online'
--filters List of comma separated udev monitor filters. Filters are applied with OR logic. Example:
'usb,tty'
--action Path to script. Script will get detected device as only argument.
--timeout Maximum execution time for script
--config Optional path to config file
Configuration file layout:
[UDEV_MONITOR]
devices = '0665:5161'
filters = 'usb'
action = '/path/to/script.sh'
udev_events = 'add'
timeout = 3600
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
udev_monitor-1.1.0.tar.gz
(6.5 kB
view hashes)
Built Distributions
udev_monitor-1.1.0-py3.10.egg
(17.2 kB
view hashes)
Close
Hashes for udev_monitor-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f812474f568c39f977755aafa58ed5ce41e84d5966d587855fc1835102b4f210 |
|
MD5 | c65e6b98bbc5ca1850020b233480addb |
|
BLAKE2b-256 | 69397ddfcaa1e46c8827c6634c431f5f1b96888ea4345ad1c8e96342472fadd4 |