gnome-session-inhibit
Inhibit system sleep, screensaver, or power management
SYNOPSIS
gnome-session-inhibit [OPTIONS] -- [COMMAND]
PARAMETERS
--inhibit
A comma-separated list of what to inhibit. Possible values are 'logout', 'switch-user', 'suspend', 'idle', 'sleep'.
--reason
A brief, human-readable reason for the inhibition.
--inhibit-only
Inhibit the session features but do not run the command specified after the '--'.
--no-checks
Disable checks for GNOME session. Use this if your application runs under another session.
--help
Show help options.
[COMMAND]
The command to execute while the session features are inhibited.
DESCRIPTION
The gnome-session-inhibit command allows you to inhibit specific functionalities of the GNOME session manager. This is useful for applications that need to prevent the system from going idle, suspending, logging out, or changing the display state (e.g., during a presentation or while playing a video). By using this tool, applications can temporarily override the user's power management and display settings to ensure uninterrupted operation. The command is often used in scripts or programs to manage system behavior in response to specific events or user actions. It works by communicating with the session manager and requesting specific inhibitions for a specified duration. The application can relinquish these inhibitions programatically by exiting, or via a specified timeout.
The command is a wrapper around the D-Bus interfaces provided by gnome-session and is the preferred method for inhibiting session management features on GNOME desktop environments. It provides a more reliable and consistent way to control session behavior compared to directly manipulating power management settings. Incorrect use of this command can prevent the system from entering power saving mode when appropriate, so it's important to use it judiciously.
CAVEATS
Incorrect usage can prevent the system from going into power saving mode. Avoid inhibiting features for longer than necessary. Make sure to always provide a reason when inhibiting features. The command will run indefinitely if no command is provided
EXAMPLES
gnome-session-inhibit --inhibit idle,sleep --reason "Video playback" totem movie.mp4
: Prevents the system from going idle or sleeping while the 'totem' video player is running.gnome-session-inhibit --inhibit logout --reason "Critical process running" my-critical-process
: Prevents the user from logging out while 'my-critical-process' is running.
EXIT STATUS
The exit status of gnome-session-inhibit depends on the command that gets executed at the end of the line. If the inhibit_only flag is used, it defaults to exit code 0
HISTORY
gnome-session-inhibit was developed as part of the GNOME desktop environment to provide a standardized way for applications to interact with the session manager and prevent unwanted session actions. It replaced older, less reliable methods of inhibiting system behavior, such as directly manipulating power management settings. The command has evolved alongside GNOME, with updates to support new features and improve reliability. Its primary goal is to ensure that applications can temporarily control session behavior without requiring root privileges or directly modifying system-wide settings.
SEE ALSO
systemd-inhibit(1), xset(1), xdg-screensaver(1)