{"id":17258626,"url":"https://github.com/xiaq/udevedu","last_synced_at":"2025-04-14T06:12:02.150Z","repository":{"id":12122648,"uuid":"14713086","full_name":"xiaq/udevedu","owner":"xiaq","description":"udevedu: udev Event Dispatcher for Unprivileged user","archived":false,"fork":false,"pushed_at":"2016-03-25T16:04:26.000Z","size":9,"stargazers_count":23,"open_issues_count":3,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-14T06:12:00.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiaq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-26T09:56:38.000Z","updated_at":"2023-11-07T09:11:07.000Z","dependencies_parsed_at":"2022-07-21T12:48:04.659Z","dependency_job_id":null,"html_url":"https://github.com/xiaq/udevedu","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaq%2Fudevedu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaq%2Fudevedu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaq%2Fudevedu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaq%2Fudevedu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaq","download_url":"https://codeload.github.com/xiaq/udevedu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830396,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T07:21:22.210Z","updated_at":"2025-04-14T06:12:02.126Z","avatar_url":"https://github.com/xiaq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# udevedu: udev Event Dispatcher for Unprivileged user\n\nudevedu is a little tool that allows you to call a Python function on udev\nevents.\n\n## Usage\n\nTo install, run: `sudo pip install .` A script named `udevedu` will be put in\n/usr/bin. (You can also do `pip install --user .`, which will put the script\n`~/.local/bin`, and you need to take care to add that to your `$PATH`.)\n\nPut hooks in `~/.config/udevedu/hooks`, which will be created the first time\n`udevedu` is invoked. Some sample hooks (read: hooks used by me, xiaq) are\ncontained in the `hook/` directory of the repository.\n\n## Anatomy of hook scripts\n\nThree functions are looked for in hook scripts: `init`, `check` and `react`.\nThey are all optional.\n\n`init` function is called after udevedu has started and collected all hook\nscripts.\n\n`check` and `react` is called when a udev event is received. If `check`\ndoesn't exist or returns a true value, `react` is called. Both are passed two\npositional arguments, `action` and `device` which come from\n[pyudev.Monitor.receive_device](http://pyudev.readthedocs.org/en/latest/api/pyudev.html#pyudev.Monitor.receive_device).\n\nNotes:\n\n* `check` is actually not necessary, but it would save you one level of\n  indentation.\n* `check` and `react` are called off the main thread, so that they may block.\n\n## Why not just write [udev rules](http://www.freedesktop.org/software/systemd/man/udev.html)?\n\nBecause udevedu runs as an unprivileged user in arbitrary environment - e.g.\nfrom your WM script so that it can call `xset`, `notify-send` etc.\n\nOther small bonuses:\n\n* You don't need to learn yet another arcane configuration language - the\n  information of the event is available as easy-to-use\n  [pyudev](http://pyudev.readthedocs.org/) objects\n* Hook functions are executed in separate threads, so that one blocking hook\n  doesn't affect other hooks\n* It's also much easier to experiment and debug - just put\n  `from pdb import set_trace; set_trace()` anywhere in the `check` or `react`\n  function.\n\n## TODO\n\n* Automatic reload of hook scripts\n\n* `pyudev.Monitor.receive_device` is deprecated, should use new interface;\n  maybe also use the asynchronous `pyudev.MonitorObserver`?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaq%2Fudevedu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaq%2Fudevedu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaq%2Fudevedu/lists"}