Swayidle: Difference between revisions
Appearance
Add Swayidle |
mNo edit summary |
||
Line 17: | Line 17: | ||
# Turn off the screen (Note that the command may differ among window managers) | # Turn off the screen (Note that the command may differ among window managers) | ||
# Suspend the system | # Suspend the system | ||
which could be set using {{ic|services.swayidle.timeouts}}. | |||
{{ic|services.swayidle.events}} is useful in case commands such as {{ic|systemctl suspend}} are manually run. | |||
{{file|~/.config/home-manager/home.nix|nix|3= | {{file|~/.config/home-manager/home.nix|nix|3= |
Revision as of 15:17, 4 July 2025
Swayidle is an idle management daemon for Wayland.
Installation
Install via Home Manager:
❄︎ ~/.config/home-manager/home.nix
services.swayidle.enable = true;
Configuration
Swayidle has a lot of flexibility in its setup, but what is usually done is as follows:
- Send notification before doing the following
- Lock screen
- Turn off the screen (Note that the command may differ among window managers)
- Suspend the system
which could be set using services.swayidle.timeouts
.
services.swayidle.events
is useful in case commands such as systemctl suspend
are manually run.
❄︎ ~/.config/home-manager/home.nix
services.swayidle =
let
# Sway
display = status: "swaymsg 'output * power ${status}'"; \
# Hyprland
# display = status: "hyprctl dispatch dpms ${status}";
# Niri
# display = status: "${pkgs.niri}/bin/niri msg action power-${status}-monitors";
in
{
enable = true;
timeouts = [
{
timeout = 15;
command = "${pkgs.libnotify}/bin/notify-send 'Locking in 5 seconds' -t 5000";
}
{
timeout = 20;
command = "${pkgs.swaylock}/bin/swaylock --daemonize";
}
{
timeout = 25;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 30;
command = "${pkgs.systemd}/bin/systemctl suspend";
}
];
events = [
{
event = "before-sleep";
command = display "off";
}
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock --daemonize";
}
{
event = "after-resume";
command = display "on";
}
{
event = "lock";
command = display "off";
}
{
event = "unlock";
command = display "on";
}
];
};