Files
2025-07-14 15:12:21 +02:00

54 lines
1.2 KiB
Nix

{ lib, pkgs, ... }:
{
# config swayidle
services.swayidle =
let
# Lock command
lock = "${pkgs.swaylock}/bin/swaylock --daemonize";
# TODO: modify "display" function based on your window manager
# Sway
display = status: "swaymsg 'output * power ${status}'";
in
{
enable = true;
timeouts = [
{
timeout = 295; # in seconds
command = "${pkgs.libnotify}/bin/notify-send 'Locking in 5 seconds' -t 5000";
}
{
timeout = 300;
command = lock;
}
{
timeout = 305;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemctl suspend-then-hibernate";
}
];
events = [
{
event = "before-sleep";
# adding duplicated entries for the same event may not work
command = (display "off") + "; " + lock;
}
{
event = "after-resume";
command = display "on";
}
{
event = "lock";
command = (display "off") + "; " + lock;
}
{
event = "unlock";
command = display "on";
}
];
};
}