nixos-config/modules/home/wms/programs/swayidle/default.nix
2025-05-09 01:26:44 -04:00

53 lines
1.3 KiB
Nix

{ config, lib, pkgs, ... }:
let
lockcommand = "${pkgs.swaylock-effects}/bin/swaylock --daemonize";
unlockcommand = "pkill -SIGUSR1 swaylock";
timeoutcommand = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
resumecommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";
in
{
config = lib.mkIf config.home.desktop.enable {
services.swayidle = {
enable = config.home.desktop.enable;
events = [
{
event = "before-sleep";
command = lockcommand;
}
{
event = "lock";
command = lockcommand;
}
{
event = "unlock";
command = unlockcommand;
}
{
event = "after-resume";
command = resumecommand;
}
];
timeouts = [
{
timeout = 1800; # 30m
command = "${pkgs.libnotify}/bin/notify-send \"Locking in 30 seconds\"";
}
{
timeout = 1830;
command = lockcommand;
}
{
timeout = 3600; # 1h
command = timeoutcommand;
resumeCommand = resumecommand;
}
{
timeout = 3605;
command = "${pkgs.systemd}/bin/systemctl suspend";
}
];
};
home.packages = with pkgs; [ sway-audio-idle-inhibit ];
};
}