{
  pkgs,
  lib,
  config,
  ...
}:
lib.mkIf config.services.swayidle.enable {
  services.swayidle =
    let
      locker = "pidof hyprlock || ${pkgs.hyprlock}/bin/hyprlock";
    in
    {
      events = [
        {
          event = "before-sleep";
          command = locker;
        }
        {
          event = "lock";
          command = locker;
        }
      ];
      timeouts = [
        {
          timeout = 300;
          command = "loginctl lock-session";
        }
        {
          timeout = 1200;
          command = "${pkgs.systemd}/bin/systemctl hibernate";
        }
      ];
    };
}
