compromise for no suspend

This commit is contained in:
Reid 2026-04-04 00:27:55 -07:00
parent 37c6c3371e
commit 4f2f4c9b52
Signed by: reidlab
GPG key ID: DAF5EAF6665839FD
3 changed files with 28 additions and 15 deletions

View file

@ -11,12 +11,7 @@ in {
default = inputs.hypridle.packages.${system}.hypridle;
example = "pkgs.hypridle";
};
desktop = mkEnableOption "Enable desktop tweaks (greatly extends the idle timeout)";
desktopMultiplier = mkOption {
type = types.int;
default = 10;
example = 10;
};
desktop = mkEnableOption "Extend screen dimming time and disable sleeping";
};
config = mkIf cfg.enable {
@ -30,12 +25,17 @@ in {
lock_cmd = "${pkgs.procps}/bin/pidof hyprlock || ${lib.getExe config.modules.desktop.hyprlock.package}";
unlock_cmd = "${pkgs.procps}/bin/pkill -USR1 hyprlock";
before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session"; # lock the screen before sleeping
before_sleep_cmd = "${pkgs.systemd}/bin/loginctl lock-session";
};
listener = let
toDesktopTimeout = t: if cfg.desktop then t * cfg.desktopMultiplier else t;
in [
listener = [
{
timeout = if !cfg.desktop
then 60 * 2 # 2 min
else 60 * 35; # 35 min
on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer
}
] ++ optionals (!cfg.desktop) [
{
timeout = toDesktopTimeout 60; # 1 min
on-timeout = "${lib.getExe pkgs.brightnessctl} -c backlight -s set 20"; # dim screen, save brightness state
@ -46,16 +46,14 @@ in {
on-timeout = "${lib.getExe pkgs.brightnessctl} -d '*:kbd_backlight' -s set 0"; # turn off keyboard backlight, save state
on-resume = "${lib.getExe pkgs.brightnessctl} -d '*:kbd_backlight' -r"; # restore previous keyboard backlight state
}
{
timeout = toDesktopTimeout (60 * 2); # 2 min
on-timeout = "${pkgs.systemd}/bin/loginctl lock-session"; # lock computer
}
{
timeout = toDesktopTimeout (60 * 15); # 15 min
on-timeout = "${pkgs.systemd}/bin/systemctl suspend"; # sleep/suspend
}
] ++ optional config.modules.desktop.niri.enable {
timeout = toDesktopTimeout (60 + 30); # 1.5 min
timeout = if !cfg.desktop
then 90 # 1.5 min
else 30 * 60; # 30 min
on-timeout = "niri msg action power-off-monitors";
};
};