#!/usr/bin/env bash usage() { cat < OPTIONS: -a | --active-workspace: Close all windows in the active workspace. -s | --special : The name of the special workspace. -h | --help: Show this help page. NOTE: If no options or workspace id is passed in, it will close all windows in all workspaces. EOF } special_flag="0" workspace_name="" workspace_id="" windows=() SCRIPTS=${SCRIPTS} if [[ -z $SCRIPTS ]]; then echo "SCRIPTS not set in the environment." echo "Using: ~/.local/scripts" SCRIPTS=~/.local/scripts fi while [[ $# -gt 0 ]]; do if [[ $1 =~ ^-s ]] || [[ $1 =~ ^--special ]]; then shift special_flag="1" workspace_name=$1 elif [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then usage && exit 0 elif [[ $1 =~ ^-a ]] || [[ $1 =~ ^--active-workspace ]]; then workspace_id=$(hyprctl activeworkspace -j | jq -r '.id') else workspace_id=$1 fi shift done if [[ $special_flag == "1" ]] && [[ -z $workspace_name ]]; then echo -e "\n[ERROR]: must supply name of the special workspace.\n" usage && exit 1 fi if [[ -n $workspace_id ]]; then windows+=($(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $workspace_id) | .address")) elif [[ -n $workspace_name ]]; then windows+=($(hyprctl clients -j | jq -r ".[] | select(.workspace.name | contains(\"$workspace_name\")) | .address")) else windows+=($(hyprctl clients -j | jq -r ".[] | .address")) fi $SCRIPTS/close-window $windows