{ lib, nixosConfig, ... }:
let
  cfg = nixosConfig.my.desktop;
in
{
  services.hypridle = lib.mkIf (cfg.enable && cfg.hyprland.enable) {
    enable = true;
    systemdTarget = "hyprland-session.target";
    settings = {
      general = {
        after_sleep_cmd = "hyprctl dispatch dpms on";
        ignore_dbus_inhibit = false;
        lock_cmd = "hyprlock";
      };
      listener = [
        {
          timeout = 300; # 2mins
          on-timeout = "hyprctl dispatch dpms off";
          on-resume = "hyprctl dispatch dpms on";
        }
      ];
    };
  };
}