fix(hypridle): enable hyprland specific stuff conditionally

This commit is contained in:
Nydragon 2024-09-21 20:36:52 +02:00
parent da918ae326
commit eee2f9ee45
Signed by: nydragon
SSH key fingerprint: SHA256:iQnIC12spf4QjWSbarmkD2No1cLMlu6TWoV7K6cYF5g

View file

@ -4,14 +4,19 @@
osConfig,
...
}:
lib.mkIf (osConfig.programs.hyprland.enable || osConfig.programs.sway.enable) {
let
hyprEnabled = osConfig.programs.hyprland.enable;
swayEnabled = osConfig.programs.sway.enable;
inherit (lib) mkIf;
in
mkIf (hyprEnabled || swayEnabled) {
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "pidof hyprlock || ${pkgs.hyprlock}/bin/hyprlock";
before_sleep_cmd = "loginctl lock-session";
after_sleep_cmd = "hyprctl dispatch dpms on";
after_sleep_cmd = mkIf hyprEnabled "hyprctl dispatch dpms on";
};
listener = [
@ -19,11 +24,11 @@ lib.mkIf (osConfig.programs.hyprland.enable || osConfig.programs.sway.enable) {
timeout = 300; # 5min
on-timeout = "loginctl lock-session"; # lock screen when timeout has passed
}
{
(mkIf hyprEnabled {
timeout = 330; # 5.5min
on-timeout = "hyprctl dispatch dpms off"; # screen off when timeout has passed
on-resume = "hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
}
})
{
timeout = 1800; # 30min
on-timeout = "systemctl suspend"; # suspend pc