From 933ce337a1539ecf8c81fab72b863f434d49f70d Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 9 Oct 2025 09:16:42 -0400 Subject: [PATCH] feat: Adds workspace picker to utils-launcher --- env/.config/utils-launcher/config.json | 5 ++ .../hypr/utils/windows/window-action-picker | 57 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/env/.config/utils-launcher/config.json b/env/.config/utils-launcher/config.json index 0804e6e..49192c8 100644 --- a/env/.config/utils-launcher/config.json +++ b/env/.config/utils-launcher/config.json @@ -43,5 +43,10 @@ "name": "Windows - close ALL", "description": "Close all windows in all workspaces.", "exec": "$SCRIPTS/hypr/windowctl close --all" + }, + { + "name": "Workspaces - stats / picker", + "description": "View information from hyprctl about currently available workspaces", + "exec": "$SCRIPTS/hypr/workspacectl picker" } ] diff --git a/env/.local/scripts/hypr/utils/windows/window-action-picker b/env/.local/scripts/hypr/utils/windows/window-action-picker index a0d14e9..1a37bdb 100755 --- a/env/.local/scripts/hypr/utils/windows/window-action-picker +++ b/env/.local/scripts/hypr/utils/windows/window-action-picker @@ -33,34 +33,6 @@ address="" move_silent_flag="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. log() { logging log --source "$THIS_FILE" "$@" @@ -224,6 +196,34 @@ handle_selection() { source "$SCRIPTS/hypr/logging" 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. [[ -z ${FZF_DEFAULT_OPTS} ]] && [[ -f $SCRIPTS/catppuccin-colors ]] && @@ -236,4 +236,5 @@ fi res=$(make_selection | handle_selection) log "Action result: $res" +# Returns "done | back | back:close" for parent script to know how to handle. echo "$res"