{ lib, ... }:
let
  common = import ../../common.nix;
  app = common.default;
  theme = import ../../theme.nix;
in
{
  wayland.windowManager.hyprland.settings = {
    monitor = [
      "DP-1, 1920x1080@144, 0x0, 1"
      "DP-3, 3840x2160@60, 1920x0, 1.5, transform, 1"
    ];

    # Autostart
    exec-once = [
      app.browser
      app.terminal
      "hypridle"
      "systemctl --user start hyprpolkitagent"
      "waypaper --restore"
    ];

    env = [
      "ELECTRON_OZONE_PLATFORM_HINT,auto" # Tell Electron apps to use Wayland
    ];

    general = {
      gaps_in = 5;
      gaps_out = 20;
      border_size = 2;
      "col.active_border" = lib.mkDefault "${theme.mauveRgb} ${theme.tealRgb} 45deg";
      "col.inactive_border" = lib.mkDefault "rgba(${theme.surface2Alpha}aa)";
      resize_on_border = true;
      allow_tearing = false;
      layout = "dwindle";
    };

    decoration = {
      rounding = 10;

      # Change transparency of focused and unfocused windows
      active_opacity = 1.0;
      inactive_opacity = 1.0;

      shadow = {
        enabled = true;
        range = 4;
        render_power = 3;
        color = lib.mkDefault theme.baseRgb;
      };

      blur = {
        enabled = true;
        size = 3;
        passes = 1;

        vibrancy = 0.1696;
      };
    };

    animations = {
      enabled = "yes, please :)";

      bezier = [
        "easeOutQuint,0.23,1,0.32,1"
        "easeInOutCubic,0.65,0.05,0.36,1"
        "linear,0,0,1,1"
        "almostLinear,0.5,0.5,0.75,1.0"
        "quick,0.15,0,0.1,1"
      ];

      animation = [
        "global, 1, 10, default"
        "border, 1, 5.39, easeOutQuint"
        "windows, 1, 4.79, easeOutQuint"
        "windowsIn, 1, 4.1, easeOutQuint, popin 87%"
        "windowsOut, 1, 1.49, linear, popin 87%"
        "fadeIn, 1, 1.73, almostLinear"
        "fadeOut, 1, 1.46, almostLinear"
        "fade, 1, 3.03, quick"
        "layers, 1, 3.81, easeOutQuint"
        "layersIn, 1, 4, easeOutQuint, fade"
        "layersOut, 1, 1.5, linear, fade"
        "fadeLayersIn, 1, 1.79, almostLinear"
        "fadeLayersOut, 1, 1.39, almostLinear"
        "workspaces, 1, 1.94, almostLinear, fade"
        "workspacesIn, 1, 1.21, almostLinear, fade"
        "workspacesOut, 1, 1.94, almostLinear, fade"
      ];
    };

    dwindle = {
      pseudotile = true; # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
      preserve_split = true; # You probably want this
    };

    master.new_status = "master";

    misc = {
      force_default_wallpaper = 0;
      disable_hyprland_logo = true;
    };

    debug.disable_logs = false;

    input = {
      kb_layout = common.keymaps.layout;
      kb_options = common.keymaps.options;
      follow_mouse = 1;
      sensitivity = 0; # -1.0 - 1.0, 0 means no modification.
      touchpad.natural_scroll = false;
    };

    gestures.workspace_swipe = false;

    device = {
      name = "logitech-g502-hero-gaming-mouse";
      sensitivity = -0.10;
    };

    windowrulev2 = [
      # Ignore maximize requests from apps
      "suppressevent maximize, class:.*"
      # Fix some dragging issues with XWayland
      "nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
      # Avoid locking in fullscreen
      "idleinhibit fullscreen, class:^(*)$"
      "idleinhibit fullscreen, title:^(*)$"
      "idleinhibit fullscreen, fullscreen:1"
    ];
  };
}