{ lib, config, pkgs, system, inputs , ... }: with lib; let cfg = config.modules.desktop.hypridle; in { options.modules.desktop.hypridle = { enable = mkEnableOption "Enable hypridle, hyprland's idle daemon"; package = mkOption { type = types.package; default = inputs.hypridle.packages.${system}.hypridle; example = "pkgs.hypridle"; }; }; config = mkIf cfg.enable { hm.services.hypridle = { enable = true; package = cfg.package; # the `date` command doesn't work if we just call hyprlock. Huh # workaround is telling hyprctl to dispatch to execute it # hacky, but i couldn't care less at the moment # TODO: change this when/if it gets patched lockCmd = "${config.modules.desktop.hyprland.package}/bin/hyprctl dispatch exec ${lib.getExe config.modules.desktop.hyprlock.package}"; unlockCmd = "pkill -USR1 hyprlock"; listeners = let hyprctl = "${config.modules.desktop.hyprland.package}/bin/hyprctl"; in [ { timeout = 90; # 1.5 min onTimeout = "${hyprctl} dispatch dpms off"; # turn off screen onResume = "${hyprctl} dispatch dpms on"; # turn it back on } { timeout = 60 * 2; # 2 min onTimeout = "loginctl lock-session"; # lock computer } { timeout = 60 * 30; # 15 min onTimeout = "systemctl suspend"; # sleep/suspend } ]; }; }; }