diff --git a/modules/home/de/hypridlelock.nix b/modules/home/de/hypridlelock.nix index 7964d95..6cb4112 100644 --- a/modules/home/de/hypridlelock.nix +++ b/modules/home/de/hypridlelock.nix @@ -11,35 +11,7 @@ config = lib.mkIf config.myConfig.de.hypridlelock.enable { services.hypridle = { enable = true; - - settings = { - general = { - lock_cmd = - let - hyprlockExe = "${lib.getExe wrappers.hyprlock}"; - in - "pidof ${hyprlockExe} || ${hyprlockExe}"; - before_sleep_cmd = "loginctl lock-session"; - after_sleep_cmd = "hyprctl dispatch dpms on"; - }; - - listener = [ - { - timeout = 300; - on-timeout = "${lib.getExe pkgs.brightnessctl} -s && ${lib.getExe pkgs.brightnessctl} -e set 10%"; - on-resume = "${lib.getExe pkgs.brightnessctl} -r"; - } - { - timeout = 600; - on-timeout = "loginctl lock-session"; - } - { - timeout = 610; - on-timeout = "hyprctl dispatch dpms off"; - on-resume = "hyprctl dispatch dpms on"; - } - ]; - }; + package = wrappers.hypridle { }; }; }; } diff --git a/wrappers/hypridle.nix b/wrappers/hypridle.nix new file mode 100644 index 0000000..513e097 --- /dev/null +++ b/wrappers/hypridle.nix @@ -0,0 +1,42 @@ +{ assembleWrapper, moduleArgs, ... }: +let + inherit (moduleArgs) pkgs; +in +{ + lockOnSleep ? false, +}: +assembleWrapper { + basePackage = pkgs.hypridle; + + flags = + let + hypridle-config = pkgs.writeText "hypridle-config" '' + general { + lock_cmd = pidof hyprlock || hyprlock + ${if lockOnSleep then "before_sleep_cmd = loginctl lock-session" else ""} + after_sleep_cmd = hyprctl dispatch dpms on + } + + listener { + timeout = 300 + on-timeout= brightnessctl -s && brightnessctl -e set 10% + on-resume = brightnessctl -r + } + + listener { + timeout = 600 + on-timeout = loginctl lock-session + } + + listener { + timeout = 610 + on-timeout = hyprctl dispatch dpms off + on-resume = hyprctl dispatch dpms on + } + ''; + in + [ + "--config" + hypridle-config + ]; +}