{pkgs, ...}: let
  hakase-workspace-switch-force = pkgs.writeShellScriptBin "hakase-workspace-switch-force" ''
    HYPRCTL="${pkgs.hyprland}/bin/hyprctl"
    JQ="${pkgs.jq}/bin/jq"

    special_workspace=$($HYPRCTL monitors -j | $JQ -r '.[] | select(.focused) | .specialWorkspace.name')

    workspace_name=''${special_workspace#*:}

    chosen_workspace_num=$1

    if [[ -z ''${chosen_workspace_num} ]]; then
      echo "Usage: $(basename "$0") [number]"
      exit 1
    fi

    if [[ "''${special_workspace}" == *"special"* ]]; then
      echo "[LOG] workspace is ''${special_workspace}"

      $HYPRCTL dispatch togglespecialworkspace "''${workspace_name}"

      $HYPRCTL dispatch workspace "''${chosen_workspace_num}"
    else
      echo "[LOG] workspace is not special"
      $HYPRCTL dispatch workspace "''${chosen_workspace_num}"
      exit 0
    fi

    exit 0
  '';

  # TODO: revise
  hakase-focus-switch = pkgs.writeShellScriptBin "hakase-focus-switch" ''
    HYPRCTL="${pkgs.hyprland}/bin/hyprctl"
    JQ="${pkgs.jq}/bin/jq"

    workspace_id=$($HYPRCTL activeworkspace -j | $JQ '.id')
    active_window=$($HYPRCTL activewindow -j)
    is_floating=$(echo "$active_window" | $JQ '.floating')

    if [ "$is_floating" == "true" ]; then
        target_addr=$($HYPRCTL clients -j | $JQ -r --argjson ws "$workspace_id" '[.[] | select(.workspace.id == $ws and .floating == false)] | .[0].address')
    else
        target_addr=$($HYPRCTL clients -j | $JQ -r --argjson ws "$workspace_id" '[.[] | select(.workspace.id == $ws and .floating == true)] | .[0].address')
    fi

    if [ "$target_addr" != "null" ] && [ -n "$target_addr" ]; then
        $HYPRCTL dispatch focuswindow address:$target_addr
    fi
  '';
in {
  home.packages = [
    hakase-workspace-switch-force
    hakase-focus-switch
  ];
}
