flake/users/guanranwang/home-manager/applications/swayidle/default.nix

48 lines
999 B
Nix
Raw Normal View History

{
pkgs,
lib,
2023-12-07 06:49:38 +00:00
config,
...
}: {
imports = [
2023-11-28 05:40:22 +00:00
../swaylock
];
2023-12-07 06:49:38 +00:00
services.swayidle = let
lock = lib.getExe config.programs.swaylock.package;
displayOn = ''${pkgs.sway}/bin/swaymsg "output * power on"'';
displayOff = ''${pkgs.sway}/bin/swaymsg "output * power off"'';
in {
enable = true;
timeouts = [
{
timeout = 60 * 9;
2023-12-16 14:48:27 +00:00
command = ''${lib.getExe pkgs.libnotify} -u critical --expire-time 60000 "60 seconds until lock!"'';
2023-12-07 06:49:38 +00:00
}
{
timeout = 60 * 10;
command = lock;
} # lock screen
{
timeout = 60 * 20;
command = displayOff;
resumeCommand = displayOn;
} # turn off screen
{
timeout = 60 * 30;
command = "systemctl suspend";
} # suspend
];
events = [
{
event = "lock";
command = lock;
} # loginctl lock-session
{
event = "before-sleep";
command = lock;
} # systemctl suspend
];
2023-11-05 12:50:08 +00:00
};
}