sleep-inhibitor


Namesleep-inhibitor JSON
Version 1.24 PyPI version JSON
download
home_pageNone
SummaryProgram to run plugins to inhibit system sleep/suspend/hibernate
upload_time2024-07-17 23:05:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseGPLv3
keywords bash systemd-inhibit sleep suspend hibernate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## SLEEP-INHIBITOR
[![PyPi](https://img.shields.io/pypi/v/sleep-inhibitor)](https://pypi.org/project/sleep-inhibitor/)
[![AUR](https://img.shields.io/aur/version/sleep-inhibitor)](https://aur.archlinux.org/packages/sleep-inhibitor/)

This is a simple program to inhibit sleep/suspend on
[systemd](https://www.freedesktop.org/wiki/Software/systemd/) based
Linux systems (or on compatible systems running
[elogind](https://github.com/elogind/elogind)). Some examples of the
default plugins provided are:

1. Plugin to inhibit sleep while any audio is playing.

2. Plugins to inhibit sleep while [Plex](https://plex.tv/) or
   [Jellyfin](https://jellyfin.org/) media server is serving media
   server is serving content.

3. Plugin to inhibit sleep while a specified process is running. I
   use this to prevent sleep while my home backup is running.

You can also create your own custom plugins. They are extremely trivial
to create as can be seen in the [provided
examples](sleep_inhibitor/plugins).
A plugin can be created in shell script or any programming language. It
must simply return an exit code to indicate whether the system should can be
slept/suspended, or not. _Sleep-inhibitor_ runs each plugin at the
period you specify (or the default 5 minutes) and checks the result to
inhibit sleep or not until at least the next check period.

The latest version of this document and code is available at
https://github.com/bulletmark/sleep-inhibitor.

:warning: **Warning**: Unfortunately this program is currently somewhat
handicapped due to [this systemd
issue](https://github.com/systemd/systemd/issues/14812). Until this
issue is addressed, your system may not automatically [re-]suspend if
still idle after it has been inhibited, even though _sleep-inhibitor_
has removed the inhibit.

## Motivation

When looking for a solution for this issue I found the
[autosuspend](https://autosuspend.readthedocs.io/en/3.0/index.html)
package but, in addition to providing plugins, that package also
implements the complete sleep, resume, and wakeup logic. I also found
the configuration and documentation confusing. I am happy with and
prefer to use the native Linux sleep systems and I desired a simpler
more lightweight approach that merely provided the ability to inhibit
these sleep systems for some special situations.

1. On Linux desktop systems, I prefer to use the standard GNOME power
   management GUI tools to automatically manage sleep/suspend (via
   systemd). All the major DE's provide similar GUI tools.

2. On Linux server systems, I prefer to use standard
[systemd](https://www.freedesktop.org/wiki/Software/systemd/) power
management to manage sleep/suspend, configured via
[`logind.conf`](https://www.freedesktop.org/software/systemd/man/logind.conf.html)
and
[`sleep.conf`](https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html).

These native approaches work well, and are easy to configure.
_Sleep-inhibitor_ assumes you are using the native systemd based sleep
facilities and merely adds the ability to add/create tiny plugins to
inhibit sleep for specified conditions. _Sleep-inhibitor_ uses
[`systemd-inhibit`](https://www.freedesktop.org/software/systemd/man/systemd-inhibit.html)
to execute the sleep inhibition lock.

## Installation

[Arch](https://www.archlinux.org/) users can just install
[_sleep-inhibitor_ from the
AUR](https://aur.archlinux.org/packages/sleep-inhibitor) then skip to
the next Configuration section.

Python 3.7 or later is required. The 3rd party ruamel.yaml package is
also required. Note [_sleep-inhibitor_ is on
PyPI](https://pypi.org/project/sleep-inhibitor/) so just ensure that
[`pipx`](https://pypa.github.io/pipx/) is installed then:

To install:

    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx install sleep-inhibitor

To upgrade:

    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx upgrade sleep-inhibitor

To remove:

    $ sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/bin pipx uninstall sleep-inhibitor

Some plugins require other software to be installed. E.g. If you use the
[`plex-media-server`](sleep_inhibitor/plugins/plex-media-server)
or
[`jellyfin-server`](sleep_inhibitor/plugins/jellyfin-server)
plugins then you must install [`curl`](https://curl.se/).

## Configuration

To start, copy the sample
[`sleep-inhibitor.conf`](sleep_inhibitor/sleep-inhibitor.conf)
configuration file to `/etc/sleep-inhibitor.conf` and then edit the
sample settings in that target file to add/configure plugins to your
requirements. The instructions and a description of all configuration
options are fully documented in the [sample configuration
file](sleep_inhibitor/sleep-inhibitor.conf).

    $ sudo cp "$(sleep-inhibitor -P)/sleep-inhibitor.conf" /etc
    $ sudoedit /etc/sleep-inhibitor.conf

## Automatic Startup as systemd Service

If you installed from source or via `pip` then copy the included
[`sleep-inhibitor.service`](sleep-/sleep-inhibitor.service)
to `/etc/systemd/system/` (note that [Arch](https://www.archlinux.org/)
users who installed from
[AUR](https://aur.archlinux.org/packages/sleep-inhibitor) can skip this
first step):

    $ sudo cp "$(sleep-inhibitor -P)/sleep-inhibitor.service" /etc/systemd/system/

Start sleep-indicator and enable it to automatically start at reboot with:

    $ sudo systemctl enable --now sleep-inhibitor

If you change the configuration file then restart with:

    $ sudo systemctl restart sleep-inhibitor

To see status and logs:

    $ systemctl status sleep-inhibitor
    $ journalctl -u sleep-inhibitor

## Plugins

To use the [standard
plugins](sleep_inhibitor/plugins)
distributed with this package just specify the plugin name (i.e. the
file name) as the `path` parameter in the [configuration
file](sleep_inhibitor/sleep-inhibitor.conf).
To use your own custom plugins, just specify the absolute path to that
plugin. E.g. you can put your custom plugin at `/home/user/bin/myplugin`
and just specify that full path in the [configuration
file](sleep_inhibitor/sleep-inhibitor.conf).

A plugin can be any executable script/program which simply returns exit
code 254 to inhibit suspend, or anything else (usually 0 of course) to
not suspend. They can be very trivial to create as the provided [example
plugins](sleep_inhibitor/plugins)
demonstrate. A plugin can be created in any language you prefer such as
Shell, Python, Ruby, C/C++, etc.

The plugin does not normally receive any arguments although you can
choose to specify arbitrary arguments to any plugin via the configuration
file, e.g. a sensitive token/password as the example
[`plex-media-server`](sleep_inhibitor/plugins/plex-media-server)
plugin requires, or the process name for the example
[`is-process-running`](sleep_inhibitor/plugins/is-process-running)
plugin.

## Command Line Usage

Type `sleep-inhibitor -h` to view the usage summary:

```
usage: sleep-inhibitor [-h] [-c CONFIG] [-p PLUGIN_DIR] [-P]

Program to run plugins to inhibit system sleep/suspend.

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        alternative configuration file
  -p PLUGIN_DIR, --plugin-dir PLUGIN_DIR
                        alternative plugin dir
  -P, --package-dir     just show directory where sample conf/service files,
                        and default plugins can be found
```

## License

Copyright (C) 2020 Mark Blakeney. This program is distributed under the
terms of the GNU General Public License. This program is free software:
you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation,
either version 3 of the License, or any later version. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at
<https://www.gnu.org/licenses/> for more details.

<!-- vim: se ai syn=markdown: -->

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sleep-inhibitor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "bash, systemd-inhibit, sleep, suspend, hibernate",
    "author": null,
    "author_email": "Mark Blakeney <mark.blakeney@bullet-systems.net>",
    "download_url": "https://files.pythonhosted.org/packages/aa/6e/35d72539e006d9f50f258f2ef958a0fcedfd61b2a63865ab330cbcac9b1b/sleep_inhibitor-1.24.tar.gz",
    "platform": null,
    "description": "## 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). Until this\nissue is addressed, your system may not automatically [re-]suspend if\nstill idle after it has been inhibited, even though _sleep-inhibitor_\nhas 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://pypa.github.io/pipx/) 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-/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<https://www.gnu.org/licenses/> for more details.\n\n<!-- vim: se ai syn=markdown: -->\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "Program to run plugins to inhibit system sleep/suspend/hibernate",
    "version": "1.24",
    "project_urls": {
        "Homepage": "https://github.com/bulletmark/sleep-inhibitor"
    },
    "split_keywords": [
        "bash",
        " systemd-inhibit",
        " sleep",
        " suspend",
        " hibernate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2aad71b1d6b8466a40483fe39fa43c577c0ae256907ab5181ecade8b2733bab3",
                "md5": "a0e219f4389c936210388dd7f3c4fa52",
                "sha256": "402f78bbaf642af92ab9e6b21fa424126e7942b655413c346834fc86a10ff479"
            },
            "downloads": -1,
            "filename": "sleep_inhibitor-1.24-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0e219f4389c936210388dd7f3c4fa52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11866,
            "upload_time": "2024-07-17T23:05:55",
            "upload_time_iso_8601": "2024-07-17T23:05:55.560298Z",
            "url": "https://files.pythonhosted.org/packages/2a/ad/71b1d6b8466a40483fe39fa43c577c0ae256907ab5181ecade8b2733bab3/sleep_inhibitor-1.24-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa6e35d72539e006d9f50f258f2ef958a0fcedfd61b2a63865ab330cbcac9b1b",
                "md5": "d80df38af1d284f206d0d747c2922abb",
                "sha256": "544f128250d8f832ff437d67642544f9ba32b1adc6c65b7e33ef912f7a3baf2e"
            },
            "downloads": -1,
            "filename": "sleep_inhibitor-1.24.tar.gz",
            "has_sig": false,
            "md5_digest": "d80df38af1d284f206d0d747c2922abb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13402,
            "upload_time": "2024-07-17T23:05:56",
            "upload_time_iso_8601": "2024-07-17T23:05:56.974493Z",
            "url": "https://files.pythonhosted.org/packages/aa/6e/35d72539e006d9f50f258f2ef958a0fcedfd61b2a63865ab330cbcac9b1b/sleep_inhibitor-1.24.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-17 23:05:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bulletmark",
    "github_project": "sleep-inhibitor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "sleep-inhibitor"
}
        
Elapsed time: 0.27722s