gnome-session-inhibit
Inhibit system sleep, screensaver, or power management
SYNOPSIS
gnome-session-inhibit [OPTIONS] COMMAND [ARGUMENTS...]
gnome-session-inhibit [OPTIONS] --inhibit-only
PARAMETERS
--help, -h
Display a help message and exit.
--version, -v
Display version information and exit.
--app-id=ID
Specifies the application ID associated with the inhibition request. This can be used by session managers or other tools to identify the source of the inhibition.
--reason=REASON
Provides a human-readable reason for the inhibition. This message might be displayed to the user if a session action is prevented.
--inhibit=FLAGS
Specifies a colon-separated list of session actions to inhibit. Available flags include:
logout: Prevent user logout.
idle: Prevent automatic idle actions (e.g., screen blanking, locking).
suspend: Prevent system suspension.
switch: Prevent user switching.
reboot: Prevent system reboot.
shutdown: Prevent system shutdown.
--inhibit-only
Causes gnome-session-inhibit to inhibit the specified actions indefinitely (or until interrupted, e.g., by Ctrl+C), without running an external command.
DESCRIPTION
gnome-session-inhibit is a command-line utility used to prevent specific actions from occurring in the GNOME desktop session while a command is running. These actions can include suspending the system, locking the screen due to idle activity, logging out, or switching users. It's particularly useful for applications that require uninterrupted operation, such as playing videos, burning optical discs, or performing long-running computations. The command works by running a specified program; as long as this program is active, the requested session inhibitions remain in effect. Once the program exits, the inhibitions are automatically released, and the GNOME session can resume its normal behavior. This mechanism ensures that critical tasks are not interrupted by automatic power-saving features or user-initiated session changes.
CAVEATS
gnome-session-inhibit requires a running GNOME session and relies on the GNOME session manager (and underlying systemd-logind or similar services) to honor the inhibition requests.
Inhibitions are advisory. A privileged user or system service can override these requests, for example, through direct D-Bus calls or system-level power management commands.
The inhibition is typically released automatically when the COMMAND executed by gnome-session-inhibit exits. If the command crashes or is forcefully terminated without proper cleanup, the inhibition might persist briefly or require manual intervention.
COMMON USE CASES
This command is frequently used by applications such as media players (to prevent screen blanking or suspend during playback), burning software (to ensure uninterrupted writing processes), and long-running backup or conversion tools. Users can also manually use it to prevent idle-related actions during a long download or compilation.
INHIBITION FLAGS EXPLAINED
The `--inhibit` flag accepts a colon-separated list of specific session actions to prevent. Understanding these flags is key to effective use:
idle: Stops the session manager from taking actions due to user inactivity (e.g., screen blanking, locking, dimming).
suspend: Prevents the system from entering a suspend (sleep) state due to inactivity or automatic power management policies.
logout: Blocks the user from logging out of the session.
switch: Prevents switching to another user session.
reboot: Prevents the system from rebooting (relevant in some integrated desktop scenarios).
shutdown: Prevents the system from shutting down.
HISTORY
gnome-session-inhibit has been a crucial part of the GNOME desktop environment's session management toolkit for many years. Its development is tied to the evolution of desktop environments needing robust ways for applications to signal critical states, preventing interruptions from automatic session management features. It serves as a user-friendly command-line wrapper for the underlying D-Bus interfaces provided by the GNOME session manager and systemd-logind, simplifying the process of requesting temporary session inhibitions for developers and advanced users alike. It ensures a smoother user experience by allowing applications to declare their need for uninterrupted operation.
SEE ALSO
systemctl(1), loginctl(1), dbus-send(1), gnome-session(1)