{
  config,
  pkgs,
  lib,
  ...
}: let
  modifier = config.windowManager.modifierKey;
  terminal = config.programs.terminal;
  termcmd = "${terminal}/bin/${terminal.pname}";
  my-deps = {
    notify-send = "${pkgs.libnotify}/bin/notify-send";
    playerctl = "${pkgs.playerctl}/bin/playerctl";
    brightnessctl = lib.getExe pkgs.brightnessctl;
    grim = "${pkgs.grim}/bin/grim";
    slurp = "${pkgs.slurp}/bin/slurp";
    amixer = "${pkgs.alsa-utils}/bin/amixer";
    chafa = "${pkgs.chafa}/bin/chafa";
    exiftool = "${pkgs.exiftool}/bin/exiftool";
    wc = "${pkgs.coreutils}/bin/wc";
    jq = "${pkgs.jq}/bin/jq";
    hyprctl = "${pkgs.hyprland}/bin/hyprctl";
    xargs = "${pkgs.findutils}/bin/xargs";
    menu = config.programs.menu.dmenuCommand;
    runmenu = config.programs.menu.drunCommand;
    fileman = "${pkgs.pcmanfm}/bin/pcmanfm";
    gawk = "${pkgs.gawk}/bin/awk";
    hyprpicker = "${pkgs.hyprpicker}/bin/hyprpicker";
    sed = "${pkgs.gnused}/bin/sed";
    lock = "${pkgs.hyprlock}/bin/hyprlock";
  };
in {
  programs.scripts = [
    {
      name = "play-pause";
      text = ''
        if [ "$(${my-deps.playerctl} --list-all | ${my-deps.wc} -l)" -lt 2 ]
        then
        ${my-deps.playerctl} play-pause
        else
        ${my-deps.playerctl} --list-all | \
        ${my-deps.xargs} -I _ ${my-deps.playerctl} --player _ metadata --format '_ - {{title}}' | \
        ${my-deps.menu} | ${my-deps.gawk} '{print $1}' | \
        ${my-deps.xargs} -I _ ${my-deps.playerctl} --player _ play-pause
        fi
      '';
      hotkeys = [
        {
          modifier = "";
          key = "XF86AudioPlay";
        }
      ];
    }
    {
      name = "bwmenu";
      text = ''
        items="$(rbw list)"
        echo "$items" | ${my-deps.menu} | xargs -I_ rbw get _ | wl-copy -n
      '';
      hotkeys = [{key = "P";}];
    }
    {
      name = "bwusernamemenu";
      text = ''
        items="$(rbw list)"
        echo "$items" | ${my-deps.menu} | xargs -I_ rbw get --field username _ \
          | wl-copy -n
      '';
      hotkeys = [
        {
          modifier = "${modifier}_CONTROL";
          key = "P";
        }
      ];
    }
    {
      name = "bwotpmenu";
      text = ''
        items="$(rbw list)"
        echo "$items" | ${my-deps.menu} | xargs -I_ rbw code _ | wl-copy -n
      '';
      hotkeys = [
        {
          modifier = "${modifier}_SHIFT";
          key = "P";
        }
      ];
    }
    {
      name = "screenshot";
      text = ''
        OUT_DIR=~/Pictures/Screenshots
        mkdir -p "$OUT_DIR"
        FILE=$OUT_DIR/$(date +"%Y-%m-%dT%H:%M:%SZ").png

        ${my-deps.grim} -g "$(${my-deps.slurp} -o)" "$FILE"
        ${my-deps.notify-send} "Screenshot Taken" "$FILE"

        cat "$FILE" | wl-copy -t image/png
      '';
      hotkeys = [
        {
          modifier = "${modifier}_SHIFT";
          key = "S";
        }
      ];
    }
    {
      name = "brightness";
      text = ''
        percent=$(${my-deps.brightnessctl} set $1 -m | awk -F, '{print $4}')

        ${my-deps.notify-send} "Brightness" -h "int:value:$percent" -h string:x-canonical-private-synchronous:brightness -t 3000
      '';
      hotkeys = [
        {
          modifier = "";
          key = "XF86MonBrightnessDown";
          args = "10%-";
        }
        {
          modifier = "SHIFT";
          key = "XF86MonBrightnessDown";
          args = "1%-";
        }
        {
          modifier = "";
          key = "XF86MonBrightnessUp";
          args = "+10%";
        }
        {
          modifier = "SHIFT";
          key = "XF86MonBrightnessUp";
          args = "+1%";
        }
      ];
      install = true;
    }
    {
      name = "picker";
      text = ''
        ${my-deps.hyprpicker} | wl-copy -n && notify-send "Copied Colour" "$(wl-paste)"
      '';
      hotkeys = [
        {
          key = "G";
        }
      ];
    }
    {
      name = "menu";
      text = ''
        ${my-deps.runmenu}
      '';
      hotkeys = [
        {
          key = "D";
        }
      ];
      install = false;
    }
    {
      name = "zoom-in";
      text = ''
        hyprctl keyword misc:cursor_zoom_factor 2
      '';
      hotkeys = [
        {
          modifier = "${modifier}";
          key = "EQUAL";
        }
      ];
      install = false;
    }
    {
      name = "zoom-out";
      text = ''
        hyprctl keyword misc:cursor_zoom_factor 1
      '';
      hotkeys = [
        {
          modifier = "${modifier}";
          key = "MINUS";
        }
      ];
      install = false;
    }
    {
      name = "raise-volume";
      text = ''
        ${my-deps.amixer} sset Master 5%+ && ${my-deps.amixer} sset Master unmute
      '';
      hotkeys = [
        {key = "bracketright";}
        {
          modifier = "";
          key = "XF86AudioRaiseVolume";
        }
      ];
      install = false;
    }
    {
      name = "lower-volume";
      text = ''
        ${my-deps.amixer} sset Master 5%-
      '';
      hotkeys = [
        {key = "bracketleft";}
        {
          modifier = "";
          key = "XF86AudioLowerVolume";
        }
      ];
      install = false;
    }
    {
      name = "skip-track";
      text = ''
        ${my-deps.playerctl} next
      '';
      hotkeys = [
        {
          modifier = "${modifier}_SHIFT";
          key = "period";
        }
        {
          modifier = "";
          key = "XF86AudioNext";
        }
      ];
      install = false;
    }
    {
      name = "skip-track-back";
      text = ''
        ${my-deps.playerctl} previous
      '';
      hotkeys = [
        {
          modifier = "${modifier}_SHIFT";
          key = "comma";
        }
        {
          modifier = "";
          key = "XF86AudioPrev";
        }
      ];
      install = false;
    }
    {
      name = "terminal";
      text = termcmd;
      hotkeys = [
        {key = "RETURN";}
      ];
      install = false;
    }
    {
      name = "fileman";
      text = my-deps.fileman;
      hotkeys = [
        {key = "O";}
      ];
      install = false;
    }
    {
      name = "lock";
      text = ''
        res=$(echo "lock
        sleep
        hibernate
        logout" | ${my-deps.menu})
        case $res in
          lock) ${my-deps.lock};;
          sleep) systemctl suspend;;
          hibernate) systemctl hibernate;;
          logout) hyprctl dispatch exit;;
        esac
      '';
      hotkeys = [
        {key = "Z";}
      ];
      install = false;
    }
    {
      name = "clone-copied-repo";
      text = ''
        url=$(wl-paste)
        ${my-deps.notify-send} "Cloning $url"
        cd ~/Documents/code
        ${termcmd} -e git clone "$url"
        ${my-deps.notify-send} "Finished cloning $url"
      '';
      install = true;
      hotkeys = [
        {
          key = "C";
          modifier = "${modifier}_SHIFT";
        }
      ];
    }
    {
      name = "select-emoji";
      text = ''
        cat ${../../lib/emotes.txt} | ${my-deps.menu} | awk '{print $1}' | wl-copy -n
      '';
      install = true;
      hotkeys = [
        {
          key = "E";
          modifier = "${modifier}_SHIFT";
        }
      ];
    }
    {
      name = "select-word";
      text = ''
        cat ${../../lib/words.txt} | ${my-deps.menu} | awk '{print $1}' | wl-copy -n
      '';
      install = true;
      hotkeys = [
        {
          key = "A";
          modifier = "${modifier}_SHIFT";
        }
      ];
    }
    {
      name = "tailscale-ip";
      text = ''
        tailscale status | ${my-deps.menu} | awk '{ print $1 }' | wl-copy -n
      '';
      install = true;
      hotkeys = [
        {
          key = "I";
        }
      ];
    }
    {
      name = "prefetch-url";
      text = ''
        nix-build -E "with import <nixpkgs> {}; fetchzip {url = \"$1\"; sha256 = lib.fakeSha256; }"
      '';
      install = true;
    }
  ];
}
