{ config, lib, pkgs, ... }:
with pkgs; let
  lockCommand = "${swaylock-effects}/bin/swaylock --daemonize";
  sleepCommand = "${systemd}/bin/systemctl suspend";
in
{
  config = lib.mkIf config.home.desktop.enable {
    services.swayidle = {
      enable = true;
      events = [
        {
          event = "before-sleep";
          command = lockCommand;
        }
        {
          event = "lock";
          command = lockCommand;
        }
      ];
      timeouts = [
        {
          timeout = 900; # 15m
          command = lockCommand;
        }
        {
          timeout = 1800; # 30m
          command = sleepCommand;
        }
      ];
    };

    home.packages = with pkgs; [ wayland-pipewire-idle-inhibit ];
  };
}
