mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-13 22:02:34 +00:00
fix: Fixes some scripts that had logging errors since logging updates.
This commit is contained in:
2
env/.config/utils-launcher/config.json
vendored
2
env/.config/utils-launcher/config.json
vendored
@@ -32,7 +32,7 @@
|
||||
{
|
||||
"name": "Windows - window stats / picker",
|
||||
"description": "View information from hyprctl about all the current windows.\n\nAllows you to choose an action you would like to perform on the selected window.",
|
||||
"exec": "$SCRIPTS/hypr/windowctl"
|
||||
"exec": "$SCRIPTS/hypr/windowctl picker"
|
||||
},
|
||||
{
|
||||
"name": "Windows - close in active workspace",
|
||||
|
||||
20
env/.local/scripts/hypr/preview-stats
vendored
20
env/.local/scripts/hypr/preview-stats
vendored
@@ -1,8 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
LOG_LABEL=$(basename $THIS_FILE)
|
||||
THIS=${THIS:-$LOG_LABEL}
|
||||
LOG_FILE=${LOG_FILE:-/tmp/$LOG_LABEL.log}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -11,9 +17,9 @@ Utility for getting fzf preview data.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $THIS [MODE] [ARG...]
|
||||
$ $THIS [COMMAND] [ARG...]
|
||||
|
||||
MODES:
|
||||
COMMAND:
|
||||
|
||||
monitor <id> <keys>: Get monitor data, optionally providing keys to return.
|
||||
window <address> <keys>: Get window data, optionally providing keys to return.
|
||||
@@ -52,7 +58,7 @@ call_jq() {
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$THIS"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
# Early out check for help flag
|
||||
if [[ $@ =~ -h ]] || [[ $@ =~ --help ]]; then
|
||||
@@ -63,9 +69,9 @@ elif [[ ! $# -ge 2 ]] || [[ $# -gt 3 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mode=$1
|
||||
arg=$2
|
||||
arg2=$3 # either optional keys or utils config.
|
||||
mode=${1:-""}
|
||||
arg=${2:-""}
|
||||
arg2=${3:-""} # either optional keys or utils config.
|
||||
|
||||
if [[ $mode == "monitor" ]]; then
|
||||
call_jq monitors "select(.id == $arg)" "$arg2"
|
||||
|
||||
17
env/.local/scripts/hypr/utils-launcher
vendored
17
env/.local/scripts/hypr/utils-launcher
vendored
@@ -1,7 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS:-""}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
LOG_LABEL=$(basename $THIS_FILE)
|
||||
THIS=${THIS:-$LOG_LABEL}
|
||||
LOG_FILE=${LOG_FILE:-/tmp/$LOG_LABEL.log}
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -28,8 +37,6 @@ launch_flag="0"
|
||||
|
||||
rows=()
|
||||
invocation_id=${RANDOM}
|
||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
SCRIPTS=${SCRIPTS}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-c" ]] || [[ $1 == "--config" ]]; then
|
||||
@@ -77,7 +84,7 @@ generate_rows() {
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$THIS"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||
log "XDG_CONFIG_HOME not set"
|
||||
@@ -102,7 +109,7 @@ fi
|
||||
file_data=$(cat $config_file)
|
||||
|
||||
# Setup colors before calling fzf.
|
||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||
[[ -z $FZF_DEFAULT_OPTS ]] &&
|
||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||
source $SCRIPTS/catppuccin-colors
|
||||
|
||||
|
||||
@@ -155,6 +155,64 @@ if [[ -z $address ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
res=$(make_selection | handle_selection)
|
||||
log "Action result: $res"
|
||||
echo "$res"
|
||||
=======
|
||||
log "Prompting for window action..."
|
||||
|
||||
choices=(
|
||||
"Focus the selected window.:Focus window"
|
||||
"Close the selected window.:Close window"
|
||||
"Close the selected window and go back to the window list.:Close window and back"
|
||||
"Move the selected window to another workspace, focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace"
|
||||
"Move the selected window to another workspace, without focusing the window.\n\nA workspace picker will be presented to choose which workspace to move to.:Move to workspace - silent"
|
||||
"Copy the window address to the system clipboard:Copy to clipboard"
|
||||
"Move back to window picker and reload windows.:Back"
|
||||
"Quit:Quit"
|
||||
)
|
||||
preview_action="$SCRIPTS/hypr/preview-stats window $address \"{title, workspace, address}\""
|
||||
choice=$(
|
||||
printf "%s\n" "${choices[@]}" |
|
||||
fzf --style=full --footer="$(action_footer)" \
|
||||
--delimiter=':' --with-nth=2 \
|
||||
--header="What should we do with the selected window?" \
|
||||
--preview-label="[ Description ]" \
|
||||
--preview="echo -e {1}; echo -e '\n\n\e[35mSelected Window:\e[0m'; $preview_action;"
|
||||
)
|
||||
if [[ $? -gt 0 ]]; then
|
||||
log --error "Unexpected fzf status: $?"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Set choice to just the action portion.
|
||||
choice="${choice#*:}"
|
||||
log "Window action choice: $choice"
|
||||
|
||||
# Set appropriate flags based on the choice and perform the action on the window address.
|
||||
if [[ $choice == "Quit" ]]; then
|
||||
exit 0
|
||||
elif [[ $choice == "Close window" ]]; then
|
||||
"$SCRIPTS/hypr/close-windows" "$address"
|
||||
elif [[ $choice == "Close window and back" ]]; then
|
||||
"$SCRIPTS/hypr/close-windows" "$address"
|
||||
should_go_back="1"
|
||||
elif [[ $choice == "Copy to clipboard" ]]; then
|
||||
echo $address | wl-copy
|
||||
elif [[ $choice == "Focus window" ]]; then
|
||||
focus_window
|
||||
elif [[ $choice == "Move to workspace" ]]; then
|
||||
move_to_workspace
|
||||
elif [[ $choice == "Move to workspace - silent" ]]; then
|
||||
move_silent_flag="1"
|
||||
move_to_workspace
|
||||
elif [[ $choice == "Back" ]]; then
|
||||
should_go_back="1"
|
||||
fi
|
||||
|
||||
# TODO: Maybe we just echo out a 'back' message.
|
||||
if [[ $should_go_back == "1" ]]; then
|
||||
exit 69
|
||||
fi
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
Reference in New Issue
Block a user