mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Adds ability to pipe addresses into close-windows script.
This commit is contained in:
21
env/.local/scripts/hypr/close-windows
vendored
21
env/.local/scripts/hypr/close-windows
vendored
@@ -1,5 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
# Allows script name to be set when called from a parent script or defaults to filename.
|
# Allows script name to be set when called from a parent script or defaults to filename.
|
||||||
THIS=${THIS:-$(basename "$THIS_FILE")}
|
THIS=${THIS:-$(basename "$THIS_FILE")}
|
||||||
@@ -43,8 +47,8 @@ all_flag="0"
|
|||||||
class_flag="0"
|
class_flag="0"
|
||||||
dry_run_flag="0"
|
dry_run_flag="0"
|
||||||
special_flag="0"
|
special_flag="0"
|
||||||
args=()
|
args=""
|
||||||
addresses=()
|
addresses=""
|
||||||
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
SCRIPTS="${SCRIPTS:-$HOME/.local/scripts}"
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -61,7 +65,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
elif [[ $1 =~ ^-s ]] || [[ $1 =~ ^--special ]]; then
|
elif [[ $1 =~ ^-s ]] || [[ $1 =~ ^--special ]]; then
|
||||||
special_flag="1"
|
special_flag="1"
|
||||||
else
|
else
|
||||||
args+=($1)
|
args+=("$1")
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@@ -122,15 +126,18 @@ elif [[ $special_flag == "1" ]]; then
|
|||||||
# Set addresses to all windows in the passed in special workspaces.
|
# Set addresses to all windows in the passed in special workspaces.
|
||||||
get_special_addresses
|
get_special_addresses
|
||||||
|
|
||||||
else
|
elif [[ -n $args ]]; then
|
||||||
# If no modes selected, then assume there were addresses passed in
|
# If no modes selected, then assume there were addresses passed in
|
||||||
# as args.
|
# as args.
|
||||||
addresses=("$args")
|
addresses=$args
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If no addresses at this point, then read from stdin, which allows addresses
|
||||||
|
# to be piped in.
|
||||||
if [[ ${#addresses} == 0 ]]; then
|
if [[ ${#addresses} == 0 ]]; then
|
||||||
log --warning "No windows found."
|
log "No window addresses supplied, reading from stdin..."
|
||||||
exit 0
|
read -r addresses
|
||||||
|
log "Addresses: ${addresses[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for address in ${addresses[@]}; do
|
for address in ${addresses[@]}; do
|
||||||
|
|||||||
4
env/.local/scripts/hypr/logging
vendored
4
env/.local/scripts/hypr/logging
vendored
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
LOG_FILE=(${LOG_FILE:-})
|
LOG_FILE=(${LOG_FILE:-})
|
||||||
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-}
|
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-}
|
||||||
LOG_LABEL=(${LOG_LABEL:-})
|
LOG_LABEL=${LOG_LABEL:-()}
|
||||||
# Run in dry run mode, which just prints to the console and does
|
# Run in dry run mode, which just prints to the console and does
|
||||||
# not log to the files.
|
# not log to the files.
|
||||||
LOG_ENABLE_DRY_RUN=${LOG_ENABLE_DRY_RUN:-"0"}
|
LOG_ENABLE_DRY_RUN=${LOG_ENABLE_DRY_RUN:-"0"}
|
||||||
@@ -144,7 +144,7 @@ setup-logging() {
|
|||||||
LOG_FILE+=("$file")
|
LOG_FILE+=("$file")
|
||||||
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
||||||
|
|
||||||
if [[ -n "$LOG_LABEL" ]]; then
|
if [[ -n $LOG_LABEL ]]; then
|
||||||
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
|
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
|
||||||
else
|
else
|
||||||
LOG_LABEL+=("$label")
|
LOG_LABEL+=("$label")
|
||||||
|
|||||||
Reference in New Issue
Block a user