{ pkgs, lib, config, ... }:
{
  home.packages = with pkgs; [
    wl-clipboard
    wtype
    wlroots
    grim
    slurp
    imv
  ];

  # Hypridle

  services.hypridle.enable = true;
  services.hypridle.settings = {
    general = {
      before_sleep_cmd = "hyprlock";
    };

    listener = [
      {
        timeout = 120;
        on-timeout = "hyprlock --grace 180";
      }
      {
        timeout = 600;
        on-timeout = "systemctl suspend";
      }
    ];
  };


  # Hyprlock

  programs.hyprlock.enable = true;
  programs.hyprlock.settings =
    let
      adjust = y: if config.machine == "earth" then builtins.floor (y / 1.75) else y;
    in {
      general = {
        hide_cursor = true;
        ignore_empty_input = true;
      };

      background = [
        {
          monitor = "";
          path = "screenshot";
          blur_passes = 2;
          blur_size = 6;
          brightness = 0.4;
          contrast = 0.5;
        }
      ];

      label = [
        {
          monitor = "";
          halign = "center";
          valign = "center";
          position = "0, ${builtins.toString (adjust 480)}";
          text = "cmd[update:1000] date '+%H:%M:%S'";
          color = "rgb(a9b1d6)";
          font_family = "Quicksand";
          font_size = adjust 102;
        }
        {
          monitor = "";
          halign = "center";
          valign = "center";
          position = "0, ${builtins.toString (adjust 370)}";
          text = "cmd[update:60000] date '+%A  %Y-%m-%d'";
          color = "rgb(a9b1d6)";
          font_family = "Quicksand";
          font_size = adjust 32;
        }
        {
          monitor = "";
          halign = "center";
          valign = "center";
          position = "0, ${builtins.toString (adjust (-240))}";
          text = "Login: $USER";
          color = "rgb(a9b1d6)";
          font_family = "Quicksand";
          font_size = adjust 26;
        }
      ];

      input-field = [
        {
          monitor = "";
          halign = "center";
          valign = "center";
          size = "${builtins.toString (adjust 800)}, ${builtins.toString (adjust 70)}";
          position = "0, ${builtins.toString (adjust (-160))}";
          dots_center = true;
          fade_on_empty = false;
          font_family = "Quicksand";
          font_color = "rgb(a9b1d6)";
          inner_color = "rgb(1a1b26)";
          outer_color = "rgb(a9b1d6)";
          check_color = "rgb(e0af68)";
          fail_color = "rgb(f7768e)";
          outline_thickness = 3;
          placeholder_text = ''<span foreground="##565f89">Password</span>'';
          shadow_passes = 2;
        }
      ];
    };

  # Swaybg

  systemd.user.services.swaybg = {
    Install.WantedBy = [ "graphical-session.target" ];

    Unit = {
      Description = "Sway background manager";
      After = [ "graphical-session-pre.target" ];
      PartOf = [ "graphical-session.target" ];
      ConditionEnvironment = "WAYLAND_DISPLAY";
    };

    Service = {
      ExecStart = "${lib.getExe pkgs.swaybg} -o '*' -i ${../../assets/background.png} -m fill";
      Restart = "always";
      RestartSec = "5";
    };
  };

  # WLuma

  # systemd.user.services.wluma = lib.mkIf (config.machine == "fire") {
  #   Install.WantedBy = [ "graphical-session.target" ];

  #   Unit = {
  #     Description = "Adjust screen brightness based on screen contents and ambient lighting";
  #     Documentation = "https://github.com/maximbaz/wluma";
  #     After = [ "graphical-session-pre.target" ];
  #     PartOf = [ "graphical-session.target" ];
  #     ConditionEnvironment = "WAYLAND_DISPLAY";
  #   };

  #   Service = {
  #     ExecStart = "${lib.getExe pkgs.wluma}";
  #     Restart = "always";
  #     RestartSec = "5";
  #     PrivateNetwork = "true";
  #     PrivateMounts = "false";
  #   };
  # };

  # xdg.configFile."wluma/config.toml".text = ''
  #   [als.iio]
  #   path = "/sys/bus/iio/devices"
  #   thresholds = { 0 = "night", 20 = "dark", 80 = "dim", 250 = "normal", 500 = "bright", 800 = "outdoors" }

  #   [[output.backlight]]
  #   name = "eDP-1"
  #   path = "/sys/class/backlight/intel_backlight"
  #   capturer = "wlroots"
  # '';
}
