{ lib, nixosConfig, ... }:
let
  cfg = nixosConfig.my.desktop;
in
{
  wayland.windowManager.hyprland = lib.mkIf (cfg.enable && cfg.hyprland.enable) {
    settings = {
      "$mod" = "SUPER";

      bind = [
        "$mod, space, exec, dms ipc call spotlight toggle"
        "alt, space, exec, dms ipc call spotlight toggle"
        "$mod, Super_L, exec, dms ipc call spotlight toggle"
        # Color Picker
        "$mod+Shift, C, exec, hyprpicker -a" # Pick color (Hex) >> clipboard

        # Screenshots
        "Super+Shift, S, exec, hyprshot --freeze --mode region --silent --clipboard-only"
        "CTRL+Shift, 4, exec, bash /home/lilly/Scripts/zipline-region.sh"
        "CTRL+Shift, 3, exec, /home/lilly/Scripts/zipline-monitor.sh"
        "CTRL+Shift, 2, exec, /home/lilly/Scripts/zipline-window.sh"
        #bindln = Ctrl,Print,exec,grim - | wl-copy Screenshot >> clipboard & file (clipboard)

        #!
        ##! Window
        #/# bind = $mod, ←/↑/→/↓,, # Focus in direction
        "$mod, Left, movefocus, l"
        "$mod, Right, movefocus, r"
        "$mod, Up, movefocus, u"
        "$mod, Down, movefocus, d"
        "$mod, BracketLeft, movefocus, l"
        "$mod, BracketRight, movefocus, r"
        #/# bind = $mod+Shift, ←/↑/→/↓,, # Move in direction
        "$mod+Shift, Left, movewindow, l"
        "$mod+Shift, Right, movewindow, r"
        "$mod+Shift, Up, movewindow, u"
        "$mod+Shift, Down, movewindow, d"
        "Alt, F4, killactive, Close (Windows)"
        "$mod, Q, killactive," # Close
        "$mod+Shift+Alt, Q, exec, hyprctl kill" # Forcefully zap a window

        # Window split ratio
        #/# binde = Super, ;/',, # Adjust split ratio
        # Positioning mode
        "Super+Alt, Space, togglefloating," # Float/Tile
        "Super, D, fullscreen, 1" # Maximize
        "Super, F, fullscreen, 0" # Fullscreen
        "Super+Alt, F, fullscreenstate, 0 3" # Fullscreen spoof
        "Super, P, pin" # Pin

        #/# bind = Super+Alt, Hash,, # Send to workspace # (1, 2, 3,...)
        # We use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev`
        "Super+Alt, code:10, movetoworkspacesilent, 1"
        "Super+Alt, code:11, movetoworkspacesilent, 2"
        "Super+Alt, code:12, movetoworkspacesilent, 3"
        "Super+Alt, code:13, movetoworkspacesilent, 4"
        "Super+Alt, code:14, movetoworkspacesilent, 5"
        "Super+Alt, code:15, movetoworkspacesilent, 6"
        "Super+Alt, code:16, movetoworkspacesilent, 7"
        "Super+Alt, code:17, movetoworkspacesilent, 8"
        "Super+Alt, code:18, movetoworkspacesilent, 9"
        "Super+Alt, code:19, movetoworkspacesilent, 10"

        # #/# bind = Super+Shift, Scroll ↑/↓,, # Send to workspace left/right
        "Super+Shift, mouse_down, movetoworkspace, r-1"
        "Super+Shift, mouse_up, movetoworkspace, r+1"
        "Super+Alt, mouse_down, movetoworkspace, -1"
        "Super+Alt, mouse_up, movetoworkspace, +1"

        #/# bind = Super+Shift, Page_↑/↓,, # Send to workspace left/right
        "Super+Alt, Page_Down, movetoworkspace, +1"
        "Super+Alt, Page_Up, movetoworkspace, -1"
        "Super+Shift, Page_Down, movetoworkspace, r+1 "
        "Super+Shift, Page_Up, movetoworkspace, r-1" 
        "Ctrl+Super+Shift, Right, movetoworkspace, r+1"
        "Ctrl+Super+Shift, Left, movetoworkspace, r-1"

        "Super+Alt, S, movetoworkspacesilent, special" # Send to scratchpad

        "Ctrl+Super, S, togglespecialworkspace,"

        ##! Workspace
        # Switching
        #/# bind = Super, Hash,, # Focus workspace # (1, 2, 3,...)
        # We use raw keycodes because some keyboard layouts register number keys as different chars. The codes can be verified with `wev`
        "Super, code:10, workspace, 1"
        "Super, code:11, workspace, 2"
        "Super, code:12, workspace, 3"
        "Super, code:13, workspace, 4"
        "Super, code:14, workspace, 5"
        "Super, code:15, workspace, 6"
        "Super, code:16, workspace, 7"
        "Super, code:17, workspace, 8"
        "Super, code:18, workspace, 9"
        "Super, code:19, workspace, 10"

        #/# bind = Ctrl+Super, ←/→,, # Focus left/right
        "Ctrl+Super, Right, workspace, r+1"
        "Ctrl+Super, Left, workspace, r-1"
        #/# bind = Ctrl+Super+Alt, ←/→,, Focus busy left/right
        "Ctrl+Super+Alt, Right, workspace, m+1"
        "Ctrl+Super+Alt, Left, workspace, m-1"
        #/# bind = Super, Page_↑/↓,, # Focus left/right
        "Super, Page_Down, workspace, +1"
        "Super, Page_Up, workspace, -1"
        "Ctrl+Super, Page_Down, workspace, r+1"
        "Ctrl+Super, Page_Up, workspace, r-1"
        #/# bind = Super, Scroll ↑/↓,, # Focus left/right
        "Super, mouse_up, workspace, +1"
        "Super, mouse_down, workspace, -1"
        "Ctrl+Super, mouse_up, workspace, r+1"
        "Ctrl+Super, mouse_down, workspace, r-1"
        ## Special
        "Ctrl+Super, BracketLeft, workspace, -1"
        "Ctrl+Super, BracketRight, workspace, +1"
        "Ctrl+Super, Up, workspace, r-5"
        "Ctrl+Super, Down, workspace, r+5"

        ##! Apps
        "Super, Return, exec, kitty"
        "Ctrl+Alt, T, exec, kitty"
        "Ctrl+Super, V, exec, pwvucontrol"
        "Ctrl+Shift, Escape, exec, \"command -v btop && kitty fish -c btop\"" # Task manager"

        # Cursed stuff
        ## Make window not amogus large
        "Ctrl+Super, Backslash, resizeactive, exact 640 480"
      ];

      bindle = [
        # Volume / Brightness control
        ",XF86MonBrightnessUp, exec, qs -c $qsConfig ipc call brightness increment || brightnessctl s 5%+"
        ",XF86MonBrightnessDown, exec, qs -c $qsConfig ipc call brightness decrement || brightnessctl s 5%-"
        ",XF86AudioRaiseVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+ -l 1.5"
        ",XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- -l 1.5"
        ",XF86AudioMute, exec, wpctl set-mute @DEFAULT_SINK@ toggle"
      ];

      bindm = [
        "$mod, mouse:272, movewindow"
        "$mod, mouse:274, movewindow"
        "$mod, mouse:273, resizewindow"
      ];

      binde = [
        "Super, Semicolon, splitratio, -0.1"
        "Super, Apostrophe, splitratio, +0.1"
      ];

      binds = {
        scroll_event_delay = 0;
        hide_special_on_workspace_change = true;
      };

      cursor = {
          zoom_factor = 1;
          zoom_rigid = false;
          hotspot_padding = 1;
      };
    };
  };
}
