{ host, config, pkgs, inputs, ... }:
let
  vars = import ../../../hosts/${host}/variables.nix;
  extraMonitorSettings = vars.extraMonitorSettings;
  keyboardLayout = vars.keyboardLayout or "us";
  keyboardVariant = vars.keyboardVariant or "";
  stylixImage = vars.stylixImage;
in
{
  home.packages = with pkgs; [
    swww
    grim
    slurp
    wl-clipboard
    swappy
    xwayland-satellite
  ];

  home.file = {
    "Pictures/Wallpapers" = {
      source = ../../../wallpapers;
      recursive = true;
    };
    ".face.icon".source = ../face.jpg;
    ".config/face.jpg".source = ../face.jpg;
  };

  programs.niri = {
    settings = {
      input = {
        keyboard = {
          xkb = {
            layout = "${keyboardLayout}";
            variant = "${keyboardVariant}";
            options = "grp:alt_caps_toggle,caps:super";
          };
          repeat-delay = 300;
          repeat-rate = 50;
        };

        touchpad = {
          tap = true;
          natural-scroll = true;
          dwt = true;
          scroll-factor = 0.8;
        };

        mouse = {
          accel-speed = 0.0;
        };
      };

      layout = {
        gaps = 8;
        center-focused-column = "never";

        border = {
          enable = true;
          width = 2;
          active = {
            color = "#${config.lib.stylix.colors.base08}";
          };
          inactive = {
            color = "#${config.lib.stylix.colors.base01}";
          };
        };

        focus-ring = {
          enable = false;
        };
      };

      spawn-at-startup = [
        { command = [ "xwayland-satellite" ":1" ]; }
        { command = [ "swww-daemon" ]; }
        { command = [ "waybar" ]; }
        { command = [ "swaync" ]; }
        { command = [ "swww" "img" "${stylixImage}" ]; }
        { command = [ "swayidle" "-w" "before-sleep" "swaylock" ]; }
      ];

      prefer-no-csd = true;

      screenshot-path = "~/Pictures/Screenshots/Screenshot-%Y-%m-%d-%H-%M-%S.png";

      environment = {
        DISPLAY = ":1";
        NIXOS_OZONE_WL = "1";
        MOZ_ENABLE_WAYLAND = "1";
        MOZ_WEBRENDER = "1";
        XDG_SESSION_TYPE = "wayland";
        WLR_NO_HARDWARE_CURSORS = "1";
        QT_QPA_PLATFORM = "wayland";
        QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
        GDK_BACKEND = "wayland,x11";
        CLUTTER_BACKEND = "wayland";
      };
    };
  };

  systemd.user.targets.niri-shutdown = {
    Unit = {
      Description = "Shutdown running niri user services";
      DefaultDependencies = "no";
      StopWhenUnneeded = true;

      Conflicts = [
        "graphical-session.target"
        "graphical-session-pre.target"
      ];
      After = [
        "graphical-session.target"
        "graphical-session-pre.target"
      ];
    };
  };
}
