Skip to main content

System suspend inhibitor

Project description

Inhibit.py

Systemd Inhibitor - Prevent system shutdowns and sleep states via stdin ON/OFF commands.

This script creates a systemd inhibitor that can be controlled via stdin. It reads ON/OFF commands from standard input and toggles the inhibition accordingly. This is useful for preventing system shutdowns and sleep states when controlled by external processes through pipes.

Basic Usage:

    # Just an example of valid input values.
    echo "ON" | inhibit
    echo "OFF" | inhibit

    # In practice, an external process emits these values.
    some_process |inhibit

    # Common arguments
    inhibit --what sleep --who "my-app" --why "processing data" --mode "block"

The script uses systemd's logind interface to create inhibitors for:

  • sleep: Prevent system sleep/suspend
  • idle: Prevent automatic idle detection

For detailed command-line options, use --help.

For detailed description of inhibitor locks, see: https://systemd.io/INHIBITOR_LOCKS/

Requirements

System requirements

These must be available and installed

  • dbus-python
  • systemd

Installing

Important: tool assumes that system provides dbus-python package.

Alternatively you can install dbus-python manually.

$ python -m venv --system-site-packages venv
$ source venv/bin/activate
$ python -m pip install inhibit
$ inhibit --version
inhibit 0.1.0

To install the package, it's recommended to use the Linux distribution default package manager.

Development

Requirements

  • uv
  • just
  • reuse
  • tox

Build

  • just check
  • just build

See Justfile.

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

inhibit-0.2.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inhibit-0.2.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file inhibit-0.2.1.tar.gz.

File metadata

  • Download URL: inhibit-0.2.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for inhibit-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2239f6135c61d5ad2f4d77199a3573bb206e80f18866b86840b9d9a678eb63a9
MD5 146b2b51746a68b7c237224a5428bccf
BLAKE2b-256 f5f0ccebcebe8b977cdac2b98cbe3bfe325ec4e992644897d776e433c665eff3

See more details on using hashes here.

File details

Details for the file inhibit-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: inhibit-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for inhibit-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 348bf80e35109f09925c5e6a8aa7bb5ac21b4de61b989d2c80100828e672fb28
MD5 0749b91341451cdfa0318ce68ff2243a
BLAKE2b-256 ee903ae60bffa39f10017624a1fe73251b230860b74294c45096a0e577e83945

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page