{ config
, lib
, pkgs
, inputs
, ...
}:
let
  makeCommand = command: {
    command = [ command ];
  };
  qs = "${pkgs.quickshell}/bin/qs";
  wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
  wallpapers = inputs.self.packages.${pkgs.system}.wallpapers;

in
{
  programs.niri.settings = {
    environment = {
      CLUTTER_BACKEND = "wayland";
      DISPLAY = ":0";
      GDK_BACKEND = "wayland,x11";
      MOZ_ENABLE_WAYLAND = "1";
      NIXOS_OZONE_WL = "1";
      QT_QPA_PLATFORM = "wayland;xcb";
      QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
      SDL_VIDEODRIVER = "wayland";
    };

    spawn-at-startup = [
      (makeCommand "${lib.getExe pkgs.hyprlock}")
      {
        command = [
          "${lib.getExe pkgs.mpvpaper}"
          "-vs"
          "-o"
          "'no-audio loop' ALL ${wallpapers}/share/wallpapers/*.mp4"
        ];
      }
      {
        command = [
          "${wl-paste}"
          "--watch"
          "cliphist"
          "store"
        ];
      }
      {
        command = [
          "${wl-paste}"
          "--type text"
          "--watch"
          "cliphist"
          "store"
        ];
      }
      {
        command = [
          "${qs}"
          "-c"
          "DankMaterialShell"
        ];
      }
    ];
    input = {
      touchpad = {
        click-method = "button-areas";
        dwt = true;
        dwtp = true;
        natural-scroll = true;
        scroll-method = "two-finger";
        tap = true;
        tap-button-map = "left-right-middle";
        middle-emulation = true;
        accel-profile = "adaptive";
      };
      focus-follows-mouse = {
        enable = true;
        max-scroll-amount = "90%";
      };
      warp-mouse-to-focus.enable = true;
      workspace-auto-back-and-forth = true;
    };

    outputs = {
      "eDP-1" = {
        scale = 1.0;
        position = {
          x = 0;
          y = 0;
        };
      };
    };

    overview = {
      workspace-shadow.enable = false;
      backdrop-color = "transparent";
    };
    gestures = {
      hot-corners.enable = true;
    };
    layout = {
      focus-ring.enable = false;
      border = {
        enable = true;
        width = 2;
        active.color = "#ff69b4";
        inactive.color = "#7d0d2d";
      };
      shadow = {
        enable = true;
      };
      preset-column-widths = [
        { proportion = 0.25; }
        { proportion = 0.5; }
        { proportion = 0.75; }
        { proportion = 1.0; }
      ];
      default-column-width = {
        proportion = 0.5;
      };

      gaps = 6;
      struts = {
        left = 0;
        right = 0;
        top = 0;
        bottom = 0;
      };

      tab-indicator = {
        hide-when-single-tab = true;
        place-within-column = true;
        position = "left";
        corner-radius = 20.0;
        gap = -12.0;
        gaps-between-tabs = 10.0;
        width = 4.0;
        length.total-proportion = 0.1;
      };
    };

    prefer-no-csd = true;
    hotkey-overlay.skip-at-startup = true;
  };
}
