From 7c08fec16bc1d81bf3289d43a396996fb4392d6f Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Mon, 6 Oct 2025 18:06:09 -0400 Subject: [PATCH] feat: Adds ability to narrow down keys returned for preview-stats. --- env/.local/scripts/hypr/preview-stats | 36 +++++++++++++++++++++------ env/.local/scripts/hypr/windowctl | 4 +-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/env/.local/scripts/hypr/preview-stats b/env/.local/scripts/hypr/preview-stats index 621a687..34994c3 100755 --- a/env/.local/scripts/hypr/preview-stats +++ b/env/.local/scripts/hypr/preview-stats @@ -15,10 +15,16 @@ USAGE: MODES: - monitor : Get monitor data. - window
: Get window data. - workspace : Get workspace data. - utlis : Get utils-launcher data. + monitor : Get monitor data, optionally providing keys to return. + window
: Get window data, optionally providing keys to return. + workspace : Get workspace data, optionally providing keys to return. + utlis : Get utils-launcher data. + +EXAMPLE: + +Here's an example of getting window data, but only returning "title", "workspace", and "address". + + $ $THIS window "0xaaaaea92a7e0" "{title, workspace, address}" EOF } @@ -46,11 +52,27 @@ mode="$1" arg="${2//\'/}" if [[ $mode == "monitor" ]]; then - hyprctl monitors -j | jq -C ".[] | select(.id == $arg)" + keys="$3" + if [[ -n $keys ]]; then + hyprctl monitors -j | jq -C ".[] | select(.id == $arg) | $keys" + else + hyprctl monitors -j | jq -C ".[] | select(.id == $arg)" + fi elif [[ $mode == "window" ]]; then - hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")" + keys="$3" + if [[ -n $keys ]]; then + hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\") | $keys" + else + hyprctl clients -j | jq -C ".[] | select(.address == \"$arg\")" + fi + elif [[ $mode == "workspace" ]]; then - hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)" + keys="$3" + if [[ -n $keys ]]; then + hyprctl workspaces -j | jq -C ".[] | select(.id == $arg) | $keys" + else + hyprctl workspaces -j | jq -C ".[] | select(.id == $arg)" + fi elif [[ $mode == "utils" ]]; then config="${3//\'/}" if [[ ! -f $config ]]; then diff --git a/env/.local/scripts/hypr/windowctl b/env/.local/scripts/hypr/windowctl index 577ca28..73894ee 100755 --- a/env/.local/scripts/hypr/windowctl +++ b/env/.local/scripts/hypr/windowctl @@ -142,8 +142,8 @@ ask_what_to_do_with_selection() { 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'; $SCRIPTS/hypr/preview-stats window $selected_value;" + --preview-label="[ Description ]" \ + --preview="echo -e {1}; echo -e '\n\n\e[35mSelected Window:\e[0m'; $SCRIPTS/hypr/preview-stats window $selected_value \"{title, workspace, address}\";" ) # Set choice to just the action portion. choice="${choice#*:}"