mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Updates windowctl subcommands, fixes some logging bugs. Need to remove old files and update keybinds to use windowctl subcommands.
This commit is contained in:
35
env/.local/scripts/hypr/logging
vendored
35
env/.local/scripts/hypr/logging
vendored
@@ -27,10 +27,13 @@
|
|||||||
# log --warning "My warning message."
|
# log --warning "My warning message."
|
||||||
# log --error "My error message."
|
# log --error "My error message."
|
||||||
#
|
#
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
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"}
|
||||||
@@ -104,14 +107,23 @@ logging() {
|
|||||||
if [[ $LOG_ENABLE_DRY_RUN == "0" ]]; then
|
if [[ $LOG_ENABLE_DRY_RUN == "0" ]]; then
|
||||||
# Loop over log files logging message to each file.
|
# Loop over log files logging message to each file.
|
||||||
for i in "${!LOG_FILE[@]}"; do
|
for i in "${!LOG_FILE[@]}"; do
|
||||||
prefix="[id: $LOG_INVOCATION_ID][time: $($SCRIPTS/isosec)][label: ${LOG_LABEL[i]}][source: $source_file] : "
|
local file=${LOG_FILE[i]}
|
||||||
m="$prefix $msg"
|
local id=$LOG_INVOCATION_ID
|
||||||
echo -e "$m" >>${LOG_FILE[i]}
|
local label=${LOG_LABEL[i]:-"$LOG_LABEL"}
|
||||||
|
local time=$("$SCRIPTS/isosec")
|
||||||
|
|
||||||
|
if [[ -z $file ]] || [[ -z $id ]] || [[ -z $label ]]; then
|
||||||
|
echo "Loggging not properly setup."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local prefix="[id: $id][time: $time][source: \e[32m$source_file\e[0m][\e[34m$label\e[0m] :"
|
||||||
|
local m="$prefix $msg"
|
||||||
|
echo -e "$m" >>"$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Also log errors and warning messages to the console.
|
# Also log errors and warning messages to the console.
|
||||||
if [[ $error_flag == "1" ]] || [[ $warn_flag == "1" ]]; then
|
if [[ $error_flag == "1" ]] || [[ $warn_flag == "1" ]]; then
|
||||||
echo -e "[id: $LOG_INVOCATION_ID]$msg"
|
echo -e "[id: $id]$msg"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Dry run mode, so just log to the console
|
# Dry run mode, so just log to the console
|
||||||
@@ -141,14 +153,19 @@ setup-logging() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Only add files that aren't already in the LOG_FILE.
|
||||||
|
if [[ ! $LOG_FILE =~ $file ]]; then
|
||||||
LOG_FILE+=("$file")
|
LOG_FILE+=("$file")
|
||||||
|
fi
|
||||||
|
|
||||||
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
LOG_INVOCATION_ID=${LOG_INVOCATION_ID:-$RANDOM}
|
||||||
|
|
||||||
if [[ -n $LOG_LABEL ]]; then
|
if [[ -n $LOG_LABEL ]] && [[ ! $LOG_LABEL =~ $label ]]; then
|
||||||
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
|
LOG_LABEL+=("${LOG_LABEL[@]}=>$label")
|
||||||
else
|
elif [[ ! $LOG_LABEL =~ $label ]]; then
|
||||||
LOG_LABEL+=("$label")
|
LOG_LABEL+=("$label")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export LOG_FILE
|
export LOG_FILE
|
||||||
export LOG_LABEL
|
export LOG_LABEL
|
||||||
export LOG_INVOCATION_ID
|
export LOG_INVOCATION_ID
|
||||||
|
|||||||
@@ -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]}
|
||||||
LOG_LABEL=$(basename "$THIS_FILE")
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
# 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.
|
||||||
@@ -98,6 +102,10 @@ close() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# MAIN
|
||||||
|
################################################################################
|
||||||
|
|
||||||
# Setup logging file and label
|
# Setup logging file and label
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$LOG_LABEL"
|
setup-logging "$LOG_LABEL"
|
||||||
|
|||||||
84
env/.local/scripts/hypr/utils/windows/focus-window
vendored
Executable file
84
env/.local/scripts/hypr/utils/windows/focus-window
vendored
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||||
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
|
THIS=${THIS:-$LOG_LABEL}
|
||||||
|
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Focuses a window, properly handling windows in special workspaces. If no address is supplied,
|
||||||
|
then we will read address from stdin.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
|
||||||
|
$ $THIS <flags> <address>
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h | --help: Show this help page.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logging utility function, use in place of echo.
|
||||||
|
log() {
|
||||||
|
logging log --source "$THIS_FILE" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prevent hyprctl dispatch calls from printing to the console.
|
||||||
|
hypr_dispatch() {
|
||||||
|
hyprctl dispatch "$@" >/dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
focus_window() {
|
||||||
|
local address=$1
|
||||||
|
log "Focusing window, selection: $address"
|
||||||
|
local name=$(hyprctl clients -j | jq -r ".[] | select(.address == \"$address\") | .workspace.name")
|
||||||
|
local active_workspace=$(hyprctl activewindow -j | jq -r ".workspace.name")
|
||||||
|
|
||||||
|
log "Window workspace: '$name', active workspace: '$active_workspace'"
|
||||||
|
if [[ $name =~ ^special ]] && [[ ! $active_workspace == $name ]]; then
|
||||||
|
log "Toggling special workspace prior to focusing window."
|
||||||
|
name="${name#special:*}"
|
||||||
|
hypr_dispatch togglespecialworkspace $name
|
||||||
|
fi
|
||||||
|
hypr_dispatch focuswindow "address:$address"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# MAIN
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Setup logging file and label.
|
||||||
|
source "$SCRIPTS/hypr/logging"
|
||||||
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||||
|
address=""
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||||
|
usage && exit 0
|
||||||
|
else
|
||||||
|
address=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $address ]]; then
|
||||||
|
log "Reading address from stdin."
|
||||||
|
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
||||||
|
# this command.
|
||||||
|
read -p "Window address: " address
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $address ]]; then
|
||||||
|
log --error "No address supplied." && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
focus_window $address && exit $?
|
||||||
@@ -7,6 +7,7 @@ set -o pipefail
|
|||||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
LOG_LABEL=$(basename "$THIS_FILE")
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
|
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||||
THIS=${THIS:-$LOG_LABEL}
|
THIS=${THIS:-$LOG_LABEL}
|
||||||
|
|
||||||
address=""
|
address=""
|
||||||
@@ -17,7 +18,7 @@ if [[ $# == 1 ]]; then
|
|||||||
else
|
else
|
||||||
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
||||||
# this command.
|
# this command.
|
||||||
read -r address
|
read -p "Window address: " address
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging utility function, use in place of echo.
|
# Logging utility function, use in place of echo.
|
||||||
@@ -41,21 +42,6 @@ hypr_dispatch() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
focus_window() {
|
|
||||||
log "Focusing window, selection: $address"
|
|
||||||
|
|
||||||
local name=$(hyprctl clients -j | jq -r ".[] | select(.address == \"$address\") | .workspace.name")
|
|
||||||
local active_workspace=$(hyprctl activewindow -j | jq -r ".workspace.name")
|
|
||||||
|
|
||||||
log "Window workspace: '$name', active workspace: '$active_workspace'"
|
|
||||||
if [[ $name =~ ^special ]] && [[ ! $active_workspace == $name ]]; then
|
|
||||||
log "Toggling special workspace prior to focusing window."
|
|
||||||
name="${name#special:*}"
|
|
||||||
hypr_dispatch togglespecialworkspace $name
|
|
||||||
fi
|
|
||||||
hypr_dispatch focuswindow "address:$address"
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_workspace_id() {
|
parse_workspace_id() {
|
||||||
local workspace_name=""
|
local workspace_name=""
|
||||||
read -r workspace_name
|
read -r workspace_name
|
||||||
@@ -141,7 +127,7 @@ handle_selection() {
|
|||||||
log "Copied window address to the clipboard."
|
log "Copied window address to the clipboard."
|
||||||
echo $address | wl-copy
|
echo $address | wl-copy
|
||||||
elif [[ $choice == "Focus window" ]]; then
|
elif [[ $choice == "Focus window" ]]; then
|
||||||
focus_window
|
"$SCRIPTS/hypr/utils/windows/focus-window" $address
|
||||||
elif [[ $choice == "Move to workspace" ]]; then
|
elif [[ $choice == "Move to workspace" ]]; then
|
||||||
move_to_workspace
|
move_to_workspace
|
||||||
elif [[ $choice == "Move to workspace - silent" ]]; then
|
elif [[ $choice == "Move to workspace - silent" ]]; then
|
||||||
@@ -162,7 +148,7 @@ handle_selection() {
|
|||||||
|
|
||||||
# Setup logging file and label.
|
# Setup logging file and label.
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$LOG_LABEL"
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||||
|
|
||||||
if [[ -z $address ]]; then
|
if [[ -z $address ]]; then
|
||||||
log --error "Address not set."
|
log --error "Address not set."
|
||||||
|
|||||||
97
env/.local/scripts/hypr/utils/windows/windowctl-picker
vendored
Executable file
97
env/.local/scripts/hypr/utils/windows/windowctl-picker
vendored
Executable file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||||
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
|
THIS=${THIS:-$LOG_LABEL}
|
||||||
|
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Shows a window picker and window details, then prompts for an action that can be
|
||||||
|
performed on the selected window.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
|
||||||
|
$ $THIS <flags>
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h | --help: Show this page.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Logging utility function, use in place of echo.
|
||||||
|
log() {
|
||||||
|
logging log --source "$THIS_FILE" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_selected_value() {
|
||||||
|
local selection=""
|
||||||
|
read -r selection
|
||||||
|
|
||||||
|
if [[ -z $selection ]]; then
|
||||||
|
log "No selected value."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Prompting for action, window: '$selection'"
|
||||||
|
|
||||||
|
local res=$(echo "$selection" | "$SCRIPTS/hypr/utils/windows/window-action-picker")
|
||||||
|
log "Action callback result: $res"
|
||||||
|
echo "$res"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_for_window_selection() {
|
||||||
|
local selected_value=$("$SCRIPTS/hypr/window-picker")
|
||||||
|
local status=$?
|
||||||
|
if [[ $status -ne 0 ]]; then
|
||||||
|
exit $status
|
||||||
|
fi
|
||||||
|
echo "$selected_value"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# MAIN
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Setup logging file and label.
|
||||||
|
source "$SCRIPTS/hypr/logging"
|
||||||
|
setup-logging $LOG_FILE $LOG_LABEL
|
||||||
|
should_quit="0"
|
||||||
|
|
||||||
|
log "Starting $THIS..."
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||||
|
usage && exit 0
|
||||||
|
elif [[ -n $1 ]]; then
|
||||||
|
address=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Load colors if they haven't been loaded already.
|
||||||
|
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||||
|
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||||
|
source $SCRIPTS/catppuccin-colors
|
||||||
|
|
||||||
|
trap 'log "Stoping..."; should_quit="1"' SIGINT
|
||||||
|
|
||||||
|
while [[ $should_quit -eq 0 ]]; do
|
||||||
|
res=$(prompt_for_window_selection | handle_selected_value)
|
||||||
|
|
||||||
|
if [[ ! $res =~ ^back ]]; then
|
||||||
|
should_quit=1
|
||||||
|
elif [[ $res == "back:close" ]]; then
|
||||||
|
sleep 0.3 # allow time for windows close, to prevent showing closed windows.
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Should quit: $should_quit"
|
||||||
|
done
|
||||||
81
env/.local/scripts/hypr/windowctl
vendored
81
env/.local/scripts/hypr/windowctl
vendored
@@ -6,26 +6,27 @@ set -o pipefail
|
|||||||
|
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
THIS=$(basename $THIS_FILE)
|
THIS=$(basename $THIS_FILE)
|
||||||
|
LOG_LABEL=$(basename $THIS_FILE)
|
||||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||||
|
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
Show a table with details about the currently active windows. You can choose a window and perform
|
Utility for performing actions on windows.
|
||||||
an action.
|
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
|
|
||||||
$ $THIS <command> <flags>
|
$ $THIS <command> <flags>
|
||||||
|
|
||||||
FLAGS:
|
FLAGS:
|
||||||
|
|
||||||
-h | --help: Show this page.
|
-h | --help: Show this page.
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
|
|
||||||
close: Close window(s).
|
close: Close window(s).
|
||||||
launch: Launch in a new terminal window, user will be prompted what to do with selected window.
|
focus: Focuses a window, handling special workspaces properly.
|
||||||
|
launch: Launches an interactive picker in a new terminal.
|
||||||
|
picker: Window picker that prompts for an action to perform on the window.
|
||||||
|
|
||||||
Run "$THIS <command> --help" for more information on a command.
|
Run "$THIS <command> --help" for more information on a command.
|
||||||
|
|
||||||
@@ -34,7 +35,6 @@ EOF
|
|||||||
|
|
||||||
window_class="com.ghostty.$THIS"
|
window_class="com.ghostty.$THIS"
|
||||||
window_padding_x="10"
|
window_padding_x="10"
|
||||||
should_quit="0"
|
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
logging log --source "$THIS_FILE" "$@"
|
logging log --source "$THIS_FILE" "$@"
|
||||||
@@ -43,11 +43,15 @@ log() {
|
|||||||
launch_usage() {
|
launch_usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
||||||
Launches in a new terminal window.
|
Launches an interactive picker in a new terminal window.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
|
|
||||||
$ $THIS launch
|
$ $THIS launch <flags>
|
||||||
|
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h | --help: Show this page.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -58,35 +62,17 @@ launch() {
|
|||||||
launch_usage && exit 0
|
launch_usage && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log "Launching terminal."
|
||||||
|
|
||||||
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
|
ghostty --class="$window_class" --window-padding-x="$window_padding_x" \
|
||||||
--keybind="ctrl+c=quit" \
|
--keybind="ctrl+c=quit" \
|
||||||
-e "${BASH_SOURCE[0]}" "${launch_args[@]}"
|
-e "${BASH_SOURCE[0]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_selected_value() {
|
show_picker() {
|
||||||
local selection=""
|
log "Showing picker..."
|
||||||
read -r selection
|
THIS="$THIS picker" "$SCRIPTS/hypr/utils/windows/windowctl-picker" "$@"
|
||||||
|
return $?
|
||||||
if [[ -z $selection ]]; then
|
|
||||||
log "No selected value."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Prompting for action, window: '$selection'"
|
|
||||||
|
|
||||||
local res=$(echo "$selection" | "$SCRIPTS/hypr/utils/windows/window-action-picker")
|
|
||||||
log "Action callback result: $res"
|
|
||||||
echo "$res"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
prompt_for_window_selection() {
|
|
||||||
local selected_value=$("$SCRIPTS/hypr/window-picker")
|
|
||||||
local status=$?
|
|
||||||
if [[ $status -ne 0 ]]; then
|
|
||||||
exit $status
|
|
||||||
fi
|
|
||||||
echo "$selected_value"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
@@ -95,16 +81,24 @@ prompt_for_window_selection() {
|
|||||||
|
|
||||||
# Setup logging file and label.
|
# Setup logging file and label.
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$THIS"
|
setup-logging "$LOG_LABEL"
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
if [[ $1 == "close" ]]; then
|
if [[ $1 == "close" ]]; then
|
||||||
shift
|
shift
|
||||||
THIS="$THIS close" "$SCRIPTS/hypr/utils/windows/close-windows" "$@"
|
THIS="$THIS close" "$SCRIPTS/hypr/utils/windows/close-windows" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
|
elif [[ $1 == "focus" ]]; then
|
||||||
|
shift
|
||||||
|
THIS="$THIS focus" "$SCRIPTS/hypr/utils/windows/focus-window" "$@"
|
||||||
|
exit $?
|
||||||
elif [[ $1 == "launch" ]]; then
|
elif [[ $1 == "launch" ]]; then
|
||||||
shift
|
shift
|
||||||
launch "$@" && exit 0
|
launch picker "$@" && exit 0
|
||||||
|
elif [[ $1 == "picker" ]]; then
|
||||||
|
shift
|
||||||
|
show_picker "$@"
|
||||||
|
exit $?
|
||||||
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||||
usage && exit 0
|
usage && exit 0
|
||||||
else
|
else
|
||||||
@@ -113,20 +107,3 @@ while [[ $# -gt 0 ]]; do
|
|||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Load colors if they haven't been loaded already.
|
|
||||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
|
||||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
|
||||||
source $SCRIPTS/catppuccin-colors
|
|
||||||
|
|
||||||
trap 'log "Stoping..."; should_quit="1"' SIGINT
|
|
||||||
|
|
||||||
while [[ $should_quit -eq 0 ]]; do
|
|
||||||
res=$(prompt_for_window_selection | handle_selected_value)
|
|
||||||
if [[ ! $res =~ ^back ]]; then
|
|
||||||
should_quit=1
|
|
||||||
elif [[ $res == "back:close" ]]; then
|
|
||||||
sleep 0.3 # allow time for windows close, to prevent showing closed windows.
|
|
||||||
fi
|
|
||||||
log "Should quit: $should_quit"
|
|
||||||
done
|
|
||||||
|
|||||||
7
gen
7
gen
@@ -74,10 +74,15 @@ generate_script() {
|
|||||||
cat >"$dest" <<'EOF'
|
cat >"$dest" <<'EOF'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||||
THIS_FILE=${BASH_SOURCE[0]}
|
THIS_FILE=${BASH_SOURCE[0]}
|
||||||
LOG_LABEL=$(basename "$THIS_FILE")
|
LOG_LABEL=$(basename "$THIS_FILE")
|
||||||
THIS=${THIS:-$LOG_LABEL}
|
THIS=${THIS:-$LOG_LABEL}
|
||||||
|
LOG_FILE=${LOG_FILE:-"/tmp/$LOG_LABEL.log"}
|
||||||
|
|
||||||
# Logging utility function, use in place of echo.
|
# Logging utility function, use in place of echo.
|
||||||
log() {
|
log() {
|
||||||
@@ -90,7 +95,7 @@ log() {
|
|||||||
|
|
||||||
# Setup logging file and label.
|
# Setup logging file and label.
|
||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$LOG_LABEL"
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||||
|
|
||||||
log "Starting $THIS..."
|
log "Starting $THIS..."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user