{
  lib,
  config,
  pkgs,
  ...
}: let
  inherit (lib) mkIf;
  cfg = config.horseman.wm.hyprland;
in {
  config = mkIf cfg.enable {
    nix-hyprland.keybindings = {
      submaps = [
        {
          name = "disable-all";
          enterBind = {
            flags = ["o"];
            mods = ["SUPER"];
            key = "ESCAPE";
          };
          exitBind = {
            flags = ["o"];
            mods = ["SUPER"];
            key = "ESCAPE";
          };

          binds = [];
        }
      ];

      binds = [
        {
          flags = [];
          mods = ["SUPER"];
          key = "SPACE";
          dispatcher = "exec";
          params = "pkill fuzzel || fuzzel";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "B";
          dispatcher = "exec";
          params = "pkill waybar || waybar";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "P";
          dispatcher = "exec";
          params = let
            a = pkgs.writeShellScriptBin "power-menu" (builtins.readFile ../../../misc/power-menu.sh);
          in "pkill fuzzel || ${a}/bin/power-menu";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "S";
          dispatcher = "exec";
          params = let
            a = pkgs.writeShellScriptBin "sound-menu" (builtins.readFile ../../../misc/sound-menu.sh);
          in "pkill fuzzel || ${a}/bin/sound-menu";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "SLASH";
          dispatcher = "exec";
          params = "pkill fuzzel || $(fuzzel --cache /dev/null --dmenu --placeholder \"Run shell command: \" -I --prompt-only \"> \")";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "RETURN";
          dispatcher = "exec";
          params = "kitty";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "Q";
          dispatcher = "killactive";
          params = "";
        }

        {
          flags = [];
          mods = [];
          key = "F11";
          dispatcher = "fullscreen";
          params = "";
        }
        {
          flags = ["o"];
          mods = ["SUPER"];
          key = "L";
          dispatcher = "exec";
          params = "hyprlock";
        }
        {
          flags = ["e"];
          mods = ["SUPER"];
          key = "TAB";
          dispatcher = "changegroupactive";
          params = "f";
        }

        {
          flags = ["e"];
          mods = ["SUPER" "SHIFT"];
          key = "TAB";
          dispatcher = "changegroupactive";
          params = "b";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "F";
          dispatcher = "togglefloating";
          params = "";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "D";
          dispatcher = "exec";
          params = "dunstctl close";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "D";
          dispatcher = "exec";
          params = "dunstctl close-all";
        }
        {
          flags = [];
          mods = ["SUPER" "ALT"];
          key = "D";
          dispatcher = "exec";
          params = "dunstctl history-pop";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "P";
          dispatcher = "pin";
          params = "";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "S";
          dispatcher = "exec";
          params = "pkill hyprshot || hyprshot -m region --clipboard-only";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "H";
          dispatcher = "movefocus";
          params = "l";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "L";
          dispatcher = "movefocus";
          params = "r";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "K";
          dispatcher = "movefocus";
          params = "u";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "J";
          dispatcher = "movefocus";
          params = "d";
        }

        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "H";
          dispatcher = "movewindow";
          params = "l";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "L";
          dispatcher = "movewindow";
          params = "r";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "K";
          dispatcher = "movewindow";
          params = "u";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "J";
          dispatcher = "movewindow";
          params = "d";
        }

        {
          flags = ["e"];
          mods = ["SUPER"];
          key = "Left";
          dispatcher = "moveactive";
          params = "-50 0";
        }
        {
          flags = ["e"];
          mods = ["SUPER"];
          key = "Right";
          dispatcher = "moveactive";
          params = "50 0";
        }
        {
          flags = ["e"];
          mods = ["SUPER"];
          key = "Up";
          dispatcher = "moveactive";
          params = "0 -50";
        }
        {
          flags = ["e"];
          mods = ["SUPER"];
          key = "Down";
          dispatcher = "moveactive";
          params = "0 50";
        }

        {
          flags = ["e"];
          mods = ["SUPER" "SHIFT"];
          key = "Left";
          dispatcher = "resizeactive";
          params = "-50 0";
        }
        {
          flags = ["e"];
          mods = ["SUPER" "SHIFT"];
          key = "Right";
          dispatcher = "resizeactive";
          params = "50 0";
        }
        {
          flags = ["e"];
          mods = ["SUPER" "SHIFT"];
          key = "Up";
          dispatcher = "resizeactive";
          params = "0 -50";
        }
        {
          flags = ["e"];
          mods = ["SUPER" "SHIFT"];
          key = "Down";
          dispatcher = "resizeactive";
          params = "0 50";
        }

        {
          flags = [];
          mods = ["SUPER"];
          key = "grave";
          dispatcher = "togglespecialworkspace";
          params = "";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "1";
          dispatcher = "workspace";
          params = "1";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "2";
          dispatcher = "workspace";
          params = "2";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "3";
          dispatcher = "workspace";
          params = "3";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "4";
          dispatcher = "workspace";
          params = "4";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "5";
          dispatcher = "workspace";
          params = "5";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "6";
          dispatcher = "workspace";
          params = "6";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "7";
          dispatcher = "workspace";
          params = "7";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "8";
          dispatcher = "workspace";
          params = "8";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "9";
          dispatcher = "workspace";
          params = "9";
        }
        {
          flags = [];
          mods = ["SUPER"];
          key = "0";
          dispatcher = "workspace";
          params = "10";
        }

        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "grave";
          dispatcher = "movetoworkspace";
          params = "special";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "1";
          dispatcher = "movetoworkspace";
          params = "1";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "2";
          dispatcher = "movetoworkspace";
          params = "2";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "3";
          dispatcher = "movetoworkspace";
          params = "3";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "4";
          dispatcher = "movetoworkspace";
          params = "4";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "5";
          dispatcher = "movetoworkspace";
          params = "5";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "6";
          dispatcher = "movetoworkspace";
          params = "6";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "7";
          dispatcher = "movetoworkspace";
          params = "7";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "8";
          dispatcher = "movetoworkspace";
          params = "8";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "9";
          dispatcher = "movetoworkspace";
          params = "9";
        }
        {
          flags = [];
          mods = ["SUPER" "SHIFT"];
          key = "0";
          dispatcher = "movetoworkspace";
          params = "10";
        }

        {
          flags = ["e"];
          mods = ["SUPER" "CONTROL"];
          key = "Right";
          dispatcher = "workspace";
          params = "e+1";
        }
        {
          flags = ["e"];
          mods = ["SUPER" "CONTROL"];
          key = "Left";
          dispatcher = "workspace";
          params = "e-1";
        }

        {
          flags = ["m"];
          mods = ["SUPER"];
          key = "mouse:272";
          dispatcher = "movewindow";
          params = "";
        }
        {
          flags = ["m"];
          mods = ["SUPER" "SHIFT"];
          key = "mouse:272";
          dispatcher = "resizewindow";
          params = "";
        }

        {
          flags = ["e" "l"];
          mods = [];
          key = "XF86AudioRaiseVolume";
          dispatcher = "exec";
          params = "pactl set-sink-volume @DEFAULT_SINK@ +5%";
        }
        {
          flags = ["e" "l"];
          mods = [];
          key = "XF86AudioLowerVolume";
          dispatcher = "exec";
          params = "pactl set-sink-volume @DEFAULT_SINK@ -5%";
        }
        {
          flags = ["e" "l"];
          mods = ["SHIFT"];
          key = "XF86AudioRaiseVolume";
          dispatcher = "exec";
          params = "pactl set-sink-volume @DEFAULT_SINK@ +1%";
        }
        {
          flags = ["e" "l"];
          mods = ["SHIFT"];
          key = "XF86AudioLowerVolume";
          dispatcher = "exec";
          params = "pactl set-sink-volume @DEFAULT_SINK@ -1%";
        }
        {
          flags = ["e" "l"];
          mods = [];
          key = "XF86AudioMute";
          dispatcher = "exec";
          params = "pactl set-sink-volume @DEFAULT_SINK@ 0%";
        }
        {
          flags = ["e" "l"];
          mods = [];
          key = "XF86MonBrightnessUp";
          dispatcher = "exec";
          params = "brightnessctl s 10%+";
        }
        {
          flags = ["e" "l"];
          mods = [];
          key = "XF86MonBrightnessDown";
          dispatcher = "exec";
          params = "brightnessctl s 10%-";
        }
        {
          flags = ["l"];
          mods = [];
          key = "XF86AudioNext";
          dispatcher = "exec";
          params = "playerctl next";
        }
        {
          flags = ["l"];
          mods = [];
          key = "XF86AudioPause";
          dispatcher = "exec";
          params = "playerctl play-pause";
        }
        {
          flags = ["l"];
          mods = [];
          key = "XF86AudioPlay";
          dispatcher = "exec";
          params = "playerctl play-pause";
        }
        {
          flags = ["l"];
          mods = [];
          key = "XF86AudioPrev";
          dispatcher = "exec";
          params = "playerctl previous";
        }
      ];
    };
  };
}
