{"id":13557309,"url":"https://github.com/bulletmark/sleep-inhibitor","last_synced_at":"2025-08-20T03:31:40.786Z","repository":{"id":45546891,"uuid":"279173356","full_name":"bulletmark/sleep-inhibitor","owner":"bulletmark","description":"Program to run plugins to inhibit system sleep/suspend","archived":false,"fork":false,"pushed_at":"2024-07-17T23:15:15.000Z","size":93,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T01:42:11.924Z","etag":null,"topics":["autosuspend","backup","jellyfin","plex","sleep","suspend"],"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/bulletmark.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-13T00:37:55.000Z","updated_at":"2024-07-22T19:05:48.000Z","dependencies_parsed_at":"2024-02-23T05:20:55.514Z","dependency_job_id":"a22452b1-c6f3-4114-a334-9cb185534a65","html_url":"https://github.com/bulletmark/sleep-inhibitor","commit_stats":{"total_commits":52,"total_committers":5,"mean_commits":10.4,"dds":"0.17307692307692313","last_synced_commit":"c90e71bd178dd746e5f51200cfe3d74c2fa256e6"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fsleep-inhibitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fsleep-inhibitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fsleep-inhibitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bulletmark%2Fsleep-inhibitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bulletmark","download_url":"https://codeload.github.com/bulletmark/sleep-inhibitor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229469547,"owners_count":18077865,"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":["autosuspend","backup","jellyfin","plex","sleep","suspend"],"created_at":"2024-08-01T12:04:16.271Z","updated_at":"2025-08-20T03:31:40.780Z","avatar_url":"https://github.com/bulletmark.png","language":"Python","funding_links":[],"categories":["Python","others"],"sub_categories":[],"readme":"## SLEEP-INHIBITOR\n[![PyPi](https://img.shields.io/pypi/v/sleep-inhibitor)](https://pypi.org/project/sleep-inhibitor/)\n[![AUR](https://img.shields.io/aur/version/sleep-inhibitor)](https://aur.archlinux.org/packages/sleep-inhibitor/)\n\nThis is a simple program to inhibit sleep/suspend on\n[systemd](https://www.freedesktop.org/wiki/Software/systemd/) based\nLinux systems (or on compatible systems running\n[elogind](https://github.com/elogind/elogind)). Some examples of the\ndefault plugins provided are:\n\n1. Plugin to inhibit sleep while any audio is playing.\n\n2. Plugins to inhibit sleep while [Plex](https://plex.tv/) or\n   [Jellyfin](https://jellyfin.org/) media server is serving media\n   server is serving content.\n\n3. Plugin to inhibit sleep while a specified process is running. I\n   use this to prevent sleep while my home backup is running.\n\nYou can also create your own custom plugins. They are extremely trivial\nto create as can be seen in the [provided\nexamples](sleep_inhibitor/plugins).\nA plugin can be created in shell script or any programming language. It\nmust simply return an exit code to indicate whether the system should can be\nslept/suspended, or not. _Sleep-inhibitor_ runs each plugin at the\nperiod you specify (or the default 5 minutes) and checks the result to\ninhibit sleep or not until at least the next check period.\n\nThe latest version of this document and code is available at\nhttps://github.com/bulletmark/sleep-inhibitor.\n\n:warning: **Warning**: Unfortunately this program is currently somewhat\nhandicapped due to [this systemd\nissue](https://github.com/systemd/systemd/issues/14812) (and/or [this\nGNOME\nissue](https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/issues/591)).\nUntil this issue is addressed, your system may not automatically\n[re-]suspend if still idle after it has been inhibited, even though\n_sleep-inhibitor_ has removed the inhibit.\n\n## Motivation\n\nWhen looking for a solution for this issue I found the\n[autosuspend](https://autosuspend.readthedocs.io/en/3.0/index.html)\npackage but, in addition to providing plugins, that package also\nimplements the complete sleep, resume, and wakeup logic. I also found\nthe configuration and documentation confusing. I am happy with and\nprefer to use the native Linux sleep systems and I desired a simpler\nmore lightweight approach that merely provided the ability to inhibit\nthese sleep systems for some special situations.\n\n1. On Linux desktop systems, I prefer to use the standard GNOME power\n   management GUI tools to automatically manage sleep/suspend (via\n   systemd). All the major DE's provide similar GUI tools.\n\n2. On Linux server systems, I prefer to use standard\n[systemd](https://www.freedesktop.org/wiki/Software/systemd/) power\nmanagement to manage sleep/suspend, configured via\n[`logind.conf`](https://www.freedesktop.org/software/systemd/man/logind.conf.html)\nand\n[`sleep.conf`](https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html).\n\nThese native approaches work well, and are easy to configure.\n_Sleep-inhibitor_ assumes you are using the native systemd based sleep\nfacilities and merely adds the ability to add/create tiny plugins to\ninhibit sleep for specified conditions. _Sleep-inhibitor_ uses\n[`systemd-inhibit`](https://www.freedesktop.org/software/systemd/man/systemd-inhibit.html)\nto execute the sleep inhibition lock.\n\n## Installation\n\n[Arch](https://www.archlinux.org/) users can just install\n[_sleep-inhibitor_ from the\nAUR](https://aur.archlinux.org/packages/sleep-inhibitor) then skip to\nthe next Configuration section.\n\nPython 3.7 or later is required. The 3rd party ruamel.yaml package is\nalso required. Note [_sleep-inhibitor_ is on\nPyPI](https://pypi.org/project/sleep-inhibitor/) so just ensure that\n[`pipx`](https://pipx.pypa.io/stable/) is installed then:\n\nTo install:\n\n    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx install sleep-inhibitor\n\nTo upgrade:\n\n    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx upgrade sleep-inhibitor\n\nTo remove:\n\n    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx uninstall sleep-inhibitor\n\nSome plugins require other software to be installed. E.g. If you use the\n[`plex-media-server`](sleep_inhibitor/plugins/plex-media-server)\nor\n[`jellyfin-server`](sleep_inhibitor/plugins/jellyfin-server)\nplugins then you must install [`curl`](https://curl.se/).\n\n## Configuration\n\nTo start, copy the sample\n[`sleep-inhibitor.conf`](sleep_inhibitor/sleep-inhibitor.conf)\nconfiguration file to `/etc/sleep-inhibitor.conf` and then edit the\nsample settings in that target file to add/configure plugins to your\nrequirements. The instructions and a description of all configuration\noptions are fully documented in the [sample configuration\nfile](sleep_inhibitor/sleep-inhibitor.conf).\n\n    $ sudo cp \"$(sleep-inhibitor -P)/sleep-inhibitor.conf\" /etc\n    $ sudoedit /etc/sleep-inhibitor.conf\n\n## Automatic Startup as systemd Service\n\nIf you installed from source or via `pip` then copy the included\n[`sleep-inhibitor.service`](sleep_inhibitor/sleep-inhibitor.service)\nto `/etc/systemd/system/` (note that [Arch](https://www.archlinux.org/)\nusers who installed from\n[AUR](https://aur.archlinux.org/packages/sleep-inhibitor) can skip this\nfirst step):\n\n    $ sudo cp \"$(sleep-inhibitor -P)/sleep-inhibitor.service\" /etc/systemd/system/\n\nStart sleep-indicator and enable it to automatically start at reboot with:\n\n    $ sudo systemctl enable --now sleep-inhibitor\n\nIf you change the configuration file then restart with:\n\n    $ sudo systemctl restart sleep-inhibitor\n\nTo see status and logs:\n\n    $ systemctl status sleep-inhibitor\n    $ journalctl -u sleep-inhibitor\n\n## Plugins\n\nTo use the [standard\nplugins](sleep_inhibitor/plugins)\ndistributed with this package just specify the plugin name (i.e. the\nfile name) as the `path` parameter in the [configuration\nfile](sleep_inhibitor/sleep-inhibitor.conf).\nTo use your own custom plugins, just specify the absolute path to that\nplugin. E.g. you can put your custom plugin at `/home/user/bin/myplugin`\nand just specify that full path in the [configuration\nfile](sleep_inhibitor/sleep-inhibitor.conf).\n\nA plugin can be any executable script/program which simply returns exit\ncode 254 to inhibit suspend, or anything else (usually 0 of course) to\nnot suspend. They can be very trivial to create as the provided [example\nplugins](sleep_inhibitor/plugins)\ndemonstrate. A plugin can be created in any language you prefer such as\nShell, Python, Ruby, C/C++, etc.\n\nThe plugin does not normally receive any arguments although you can\nchoose to specify arbitrary arguments to any plugin via the configuration\nfile, e.g. a sensitive token/password as the example\n[`plex-media-server`](sleep_inhibitor/plugins/plex-media-server)\nplugin requires, or the process name for the example\n[`is-process-running`](sleep_inhibitor/plugins/is-process-running)\nplugin.\n\n## Command Line Usage\n\nType `sleep-inhibitor -h` to view the usage summary:\n\n```\nusage: sleep-inhibitor [-h] [-c CONFIG] [-p PLUGIN_DIR] [-P]\n\nProgram to run plugins to inhibit system sleep/suspend.\n\noptions:\n  -h, --help            show this help message and exit\n  -c CONFIG, --config CONFIG\n                        alternative configuration file\n  -p PLUGIN_DIR, --plugin-dir PLUGIN_DIR\n                        alternative plugin dir\n  -P, --package-dir     just show directory where sample conf/service files,\n                        and default plugins can be found\n```\n\n## License\n\nCopyright (C) 2020 Mark Blakeney. This program is distributed under the\nterms of the GNU General Public License. This program is free software:\nyou can redistribute it and/or modify it under the terms of the GNU\nGeneral Public License as published by the Free Software Foundation,\neither version 3 of the License, or any later version. This program is\ndistributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at\n\u003chttps://en.wikipedia.org/wiki/GNU_General_Public_License\u003e for more details.\n\n\u003c!-- vim: se ai syn=markdown: --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbulletmark%2Fsleep-inhibitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbulletmark%2Fsleep-inhibitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbulletmark%2Fsleep-inhibitor/lists"}