mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Adds workspace picker to utils-launcher
This commit is contained in:
5
env/.config/utils-launcher/config.json
vendored
5
env/.config/utils-launcher/config.json
vendored
@@ -43,5 +43,10 @@
|
|||||||
"name": "Windows - close ALL",
|
"name": "Windows - close ALL",
|
||||||
"description": "Close all windows in all workspaces.",
|
"description": "Close all windows in all workspaces.",
|
||||||
"exec": "$SCRIPTS/hypr/windowctl close --all"
|
"exec": "$SCRIPTS/hypr/windowctl close --all"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Workspaces - stats / picker",
|
||||||
|
"description": "View information from hyprctl about currently available workspaces",
|
||||||
|
"exec": "$SCRIPTS/hypr/workspacectl picker"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -33,34 +33,6 @@ address=""
|
|||||||
move_silent_flag="0"
|
move_silent_flag="0"
|
||||||
show_back_choice="0"
|
show_back_choice="0"
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
|
||||||
usage && exit 0
|
|
||||||
elif [[ $1 == "-a" ]] || [[ $1 == "--active" ]]; then
|
|
||||||
|
|
||||||
class=$(hyprctl activewindow -j | jq -r '.class')
|
|
||||||
if [[ $class == "com.ghostty.windowctl" ]]; then
|
|
||||||
# Select the previously focused window if we were launched in a new terminal window.
|
|
||||||
address=$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 1) | .address')
|
|
||||||
else
|
|
||||||
# Select the active address if not.
|
|
||||||
address=$(hyprctl activewindow -j | jq -r '.address')
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ $1 == "--show-back" ]]; then
|
|
||||||
show_back_choice="1"
|
|
||||||
else
|
|
||||||
address=$1
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
|
||||||
# this command.
|
|
||||||
if [[ -z $address ]]; then
|
|
||||||
read -p "Window address: " address
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Logging utility function, use in place of echo.
|
# Logging utility function, use in place of echo.
|
||||||
log() {
|
log() {
|
||||||
logging log --source "$THIS_FILE" "$@"
|
logging log --source "$THIS_FILE" "$@"
|
||||||
@@ -224,6 +196,34 @@ handle_selection() {
|
|||||||
source "$SCRIPTS/hypr/logging"
|
source "$SCRIPTS/hypr/logging"
|
||||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||||
|
usage && exit 0
|
||||||
|
elif [[ $1 == "-a" ]] || [[ $1 == "--active" ]]; then
|
||||||
|
|
||||||
|
class=$(hyprctl activewindow -j | jq -r '.class')
|
||||||
|
if [[ $class == "com.ghostty.windowctl" ]]; then
|
||||||
|
# Select the previously focused window if we were launched in a new terminal window.
|
||||||
|
address=$(hyprctl clients -j | jq -r '.[] | select(.focusHistoryID == 1) | .address')
|
||||||
|
else
|
||||||
|
# Select the active address if not.
|
||||||
|
address=$(hyprctl activewindow -j | jq -r '.address')
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif [[ $1 == "--show-back" ]]; then
|
||||||
|
show_back_choice="1"
|
||||||
|
else
|
||||||
|
address=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# If an address not supplied then read from stdin, which allows us to pipe the address into
|
||||||
|
# this command.
|
||||||
|
if [[ -z $address ]]; then
|
||||||
|
read -p "Window address: " address
|
||||||
|
fi
|
||||||
|
|
||||||
# Load colors if they haven't been loaded already.
|
# Load colors if they haven't been loaded already.
|
||||||
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
[[ -z ${FZF_DEFAULT_OPTS} ]] &&
|
||||||
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
[[ -f $SCRIPTS/catppuccin-colors ]] &&
|
||||||
@@ -236,4 +236,5 @@ fi
|
|||||||
|
|
||||||
res=$(make_selection | handle_selection)
|
res=$(make_selection | handle_selection)
|
||||||
log "Action result: $res"
|
log "Action result: $res"
|
||||||
|
# Returns "done | back | back:close" for parent script to know how to handle.
|
||||||
echo "$res"
|
echo "$res"
|
||||||
|
|||||||
Reference in New Issue
Block a user