caffeine
Prevent system from going to sleep
TLDR
Start a caffeine server
Display help
Display version
SYNOPSIS
caffeine [-h] [-a] [-s] [-t]
PARAMETERS
-h, --help
Show help message and exit.
-a, --active
Print 1 if caffeine is active, 0 otherwise.
-s, --status
Print status: enabled or disabled.
-t, --toggle
Toggle caffeine inhibition on/off.
DESCRIPTION
Caffeine is a simple command-line utility for Linux desktops that temporarily prevents the system from suspending, blanking the screen, or activating the screensaver/lock screen. It achieves this by sending inhibition requests via D-Bus to the desktop environment's power management services, primarily supporting GNOME, MATE, and similar sessions.
Ideal for scenarios like watching videos, giving presentations, coding marathons, or remote desktop sessions where interruptions from idle timeouts are undesirable. When toggled on, it overrides user-configured idle settings until manually disabled. The tool is lightweight, dependency-minimal, and integrates seamlessly without running as a persistent daemon.
Status can be queried to check if inhibition is active, making it scriptable for automation, such as inhibiting during specific processes. Note that it respects manual sleep commands or lid-close events unless configured otherwise. Primarily designed for X11; Wayland compatibility depends on the compositor (e.g., works with GNOME on Wayland via extensions).
Unlike heavier alternatives, caffeine focuses solely on toggle functionality, promoting ease of use in daily workflows. Widely used in Ubuntu derivatives but portable across distros with Python/DBus support.
CAVEATS
Requires caffeine package installed. Best on GNOME/MATE X11 sessions; Wayland support varies. Does not block lid-close or manual suspend.
INSTALLATION
Ubuntu/Debian: sudo apt install caffeine
Fedora: sudo dnf install caffeine
Arch: sudo pacman -S caffeine-ng
EXAMPLES
caffeine -t # Toggle status
if caffeine -a; then caffeine -t; fi # Disable if active
watch -n1 caffeine -s # Monitor status
HISTORY
Developed around 2012 as indicator-caffeine for Ubuntu Unity/GNOME. Evolved into standalone CLI tool. Maintained on GitHub (caffeine-app), now available via apt/snap/flatpak across distros.
SEE ALSO
systemd-inhibit(1), loginctl(1), xscreensaver-command(1), gnome-screensaver-command(1)


