{ pkgs, ... }:
{
  home.packages = builtins.attrValues { inherit (pkgs) brillo; };

  services.swayidle = {
    enable = true;
    events = [
      {
        event = "before-sleep";
        command = "${pkgs.wl-lockscreen}/bin/wl-lockscreen";
      }
      {
        event = "lock";
        command = "${pkgs.wl-lockscreen}/bin/wl-lockscreen";
      }
    ];
    timeouts = [
      {
        timeout = 60;
        command = "${pkgs.brillo}/bin/brillo -e -S 10 -u 1000000";
        resumeCommand = "${pkgs.brillo}/bin/brillo -e -S 100";
      }
      {
        timeout = 120;
        command = "${pkgs.brillo}/bin/brillo -e -S 0; ${pkgs.wl-lockscreen}/bin/wl-lockscreen";
        resumeCommand = "${pkgs.brillo}/bin/brillo -e -S 100";
      }
    ];
  };
}
