What is swayidle and its compatibility
masterext-idle-notify protocol.repository·master·Indexed 20 days ago
https://github.com/swaywm/swayidleAn idle management daemon for Wayland compositors that monitors user activity and triggers actions when the system becomes idle. It is designed for Sway and compatible with any Wayland compositor implementing the ext-idle-notify protocol. Supports timeout commands, systemd/elogind hooks, and configuration via CLI flags or config files.
ext-idle-notify protocol.swayidle using your distribution's package manager.To build swayidle from source, ensure you have the following dependencies installed:
meson (Compile-time dependency)waylandwayland-protocols (Compile-time dependency)scdoc (Optional, for generating man pages)git (Compile-time dependency)Follow these steps to build and install:
meson build/
ninja -C build/
sudo ninja -C build/ installWhen swayidle executes a command, it spawns it using sh -c "<command>".
Execution Modes:
swayidle does not wait for them to complete.-w flag is used, swayidle will block and wait for the spawned process to exit before continuing its event loop. This is useful if subsequent idle actions depend on the completion of previous ones.If no configuration file is specified via the -C flag, swayidle searches for a config file in the following locations (in order):
$XDG_CONFIG_HOME/swayidle/config (defaults to $HOME/.config/swayidle/config if $XDG_CONFIG_HOME is unset)$HOME/.swayidle/configSYSCONFDIR) /swayidle/config.Config File Format:
The configuration file consists of one command per line. Lines starting with # are treated as comments. Shell expansion is supported for paths and variables within the file.
If compiled with systemd or elogind support, swayidle can respond to system power and session events.
Available hooks:
before-sleep <command>: Runs a command before the system goes to sleep.after-resume <command>: Runs a command after the system resumes.lock <command>: Runs a command when a session lock signal is received.unlock <command>: Runs a command when a session unlock signal is received.idlehint <seconds>: Sets an idle hint to the session manager after the specified number of seconds.before-sleep <command>
after-resume <command>
lock <command>
unlock <command>
idlehint <seconds>The swayidle command-line interface allows you to configure behavior via flags or by providing a path to a configuration file.
Command-line flags:
-h: Display the help menu.-C <path>: Specify a custom path to a configuration file.-d: Enable debug logging.-w: Wait for commands to finish before proceeding.-S <seat_name>: Pick a specific seat to work with.Command Syntax:
You can pass commands directly as arguments. The general pattern is swayidle [OPTIONS] <command> [args...].
swayidle [OPTIONS]
-h this help menu
-C path to config file
-d debug
-w wait for command to finish
-S pick the seat to work withThe timeout command triggers an action after a specified period of inactivity. It supports an optional resume command that runs when activity is detected.
Syntax:
timeout <seconds> <command> [resume <command>]
<seconds>: A numeric value representing the idle duration in seconds.<command>: The command to execute when the timeout is reached.resume <command>: (Optional) The command to execute when the user resumes activity.timeout <seconds> <command>
timeout <seconds> <command> resume <command>