nixos_config/home/modules/services/swayidle.nix

35 lines
835 B
Nix

{ pkgs, ... }:
let
commands = import ../../../lib/commands.nix { inherit pkgs; };
inherit (commands) notify lock display;
in
{
services.swayidle = {
enable = true;
timeouts = [
{
timeout = 120;
command = "${notify} 'Locking in 5 seconds' -t 5000";
}
{
timeout = 125;
command = lock;
}
{
timeout = 125;
command = display "off";
resumeCommand = display "on";
}
{
timeout = 600;
command = "${pkgs.systemd}/bin/systemctl suspend";
}
];
events = {
before-sleep = "display off; systemctl --user stop libinput-gestures; ${lock}";
after-resume = "display on; systemctl --user start libinput-gestures";
lock = (display "off") + "; " + lock;
unlock = display "on";
};
};
}