mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Adds apple calendar web app, updates close-all-windows script to work on workspaces.
This commit is contained in:
65
env/.local/scripts/close-all-windows
vendored
65
env/.local/scripts/close-all-windows
vendored
@@ -1,5 +1,62 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
hyprctl clients -j | \
|
||||
jq '.[] | .address' | \
|
||||
xargs -I{} hyprctl dispatch closewindow address:{}
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Close all windows for a workspace id, special workspace name, or all windows.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ close-all-windows [OPTIONS] <ID (optional)>
|
||||
|
||||
OPTIONS:
|
||||
-a | --active-workspace: Close all windows in the active workspace.
|
||||
-s | --special <name>: 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=()
|
||||
|
||||
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
|
||||
|
||||
for w in ${windows[@]}; do
|
||||
echo "Closing window address: $w"
|
||||
hyprctl dispatch closewindow address:$w
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user