LinuxCommandLibrary

swayidle

Idle management daemon for Sway

TLDR

Lock screen on idle

$ swayidle timeout [300] 'swaylock -f'
copy
Turn off display
$ swayidle timeout [600] 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
copy
Lock before sleep
$ swayidle before-sleep 'swaylock -f'
copy
Multiple timeouts
$ swayidle timeout [300] 'swaylock -f' timeout [600] 'systemctl suspend'
copy
With lock event
$ swayidle lock 'swaylock -f'
copy

SYNOPSIS

swayidle [options] [events]

DESCRIPTION

swayidle is an idle management daemon for the Sway Wayland compositor that triggers commands based on user inactivity. It supports multiple timeout events that execute commands after specified periods of idle time, enabling staged power management such as dimming the screen, locking, and eventually suspending.
Resume actions execute when user activity is detected after a timeout, allowing reversal of timeout effects like turning displays back on. The before-sleep and after-resume events integrate with systemd sleep/wake cycles, commonly used to ensure the screen is locked before the system suspends.
Lock and unlock events respond to session lock signals from logind, enabling coordination with external lock requests such as those from the system settings or other applications.

PARAMETERS

timeout SECONDS COMMAND

Run after idle time.
resume COMMAND
Run on activity.
before-sleep COMMAND
Run before suspend.
after-resume COMMAND
Run after wake.
lock COMMAND
Run on lock event.
unlock COMMAND
Run on unlock.
-w
Wait for command.

CAVEATS

Wayland/Sway only. Commands run as shell. Audio may prevent idle.

HISTORY

swayidle is the idle manager for Sway compositor. It handles power management and screen locking triggers.

SEE ALSO

sway(1), swaylock(1), systemd(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community