From 8b195186975229a5dedff13de2380dd4ecc35b0b Mon Sep 17 00:00:00 2001 From: Henro Veijer Date: Fri, 27 Feb 2026 22:31:20 +0100 Subject: [PATCH] no overflow if no overflow --- .../hypr/scripts/hyprscroll-overflow.sh | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh b/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh index d5baae745..5a28cc0ce 100755 --- a/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh +++ b/henrovnix_ok/assets/conf/desktop/hypr/scripts/hyprscroll-overflow.sh @@ -26,6 +26,7 @@ json_escape() { } fail_json() { + # NOTE: errors SHOULD still show (so you notice), hence JSON output here. local msg="hyprscroll-overflow: ${1:-unknown error}" printf '{"text":"%s !","tooltip":"%s","class":"error"}\n' \ "$(json_escape "$ICON")" "$(json_escape "$msg")" @@ -45,9 +46,42 @@ read -r focused_mon_id focused_ws_id < <( [[ -n "${focused_mon_id:-}" && -n "${focused_ws_id:-}" ]] || fail_json "no focused monitor/workspace" +# Current layout (needed for both normal + --pick paths) +layout="$(hyprctl getoption general:layout 2>/dev/null | awk '/str:/ {print $2; exit}' || true)" +layout="${layout:-}" + # Collect windows (current ws + current monitor, mapped only) clients_json="$(hyprctl -j clients 2>/dev/null)" || fail_json "failed to read clients" +# Click action: pick a window and focus it +if [[ "${1:-}" == "--pick" ]]; then + # Build menu lines: address at end so we can parse it back reliably. + menu="$( + jq -r --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" ' + [ .[] + | select(.mapped == true) + | select(.workspace.id == $ws) + | select(.monitor == $mid) + | {address, class, title} + ] + | map("[\(.class)] \(.title) \(.address)") + | .[] + ' <<<"$clients_json" + )" || exit 0 + + [[ -n "${menu:-}" ]] || exit 0 + + # shellcheck disable=SC2086 + choice="$(printf '%s\n' "$menu" | eval "$DMENU_CMD" || true)" + [[ -n "${choice:-}" ]] || exit 0 + + addr="$(awk '{print $NF}' <<<"$choice")" + [[ "$addr" =~ ^0x[0-9a-fA-F]+$ ]] || exit 0 + + hyprctl dispatch focuswindow "address:${addr}" >/dev/null 2>&1 || exit 0 + exit 0 +fi + # Tooltip list (multiline) # Include a stable selector: address (hex), plus class + title for humans. tooltip_list="$( @@ -80,41 +114,8 @@ max_visible="$(awk -v w="$COLUMN_WIDTH" 'BEGIN{ if (w<=0) {print 1} else {print overflow=$(( win_count - max_visible )) -layout="$(hyprctl getoption general:layout 2>/dev/null | awk '/str:/ {print $2; exit}' || true)" -layout="${layout:-}" - -# Click action: pick a window and focus it -if [[ "${1:-}" == "--pick" ]]; then - # Build menu lines: address at end so we can parse it back reliably. - menu="$( - jq -r --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" ' - [ .[] - | select(.mapped == true) - | select(.workspace.id == $ws) - | select(.monitor == $mid) - | {address, class, title} - ] - | map("[\(.class)] \(.title) \(.address)") - | .[] - ' <<<"$clients_json" - )" || exit 0 - - [[ -n "${menu:-}" ]] || exit 0 - - # shellcheck disable=SC2086 - choice="$(printf '%s\n' "$menu" | eval "$DMENU_CMD" || true)" - [[ -n "${choice:-}" ]] || exit 0 - - addr="$(awk '{print $NF}' <<<"$choice")" - [[ "$addr" =~ ^0x[0-9a-fA-F]+$ ]] || exit 0 - - # Focus brings it forward in normal tiling usage; for tricky stacking cases, - # you can also add: hyprctl dispatch bringactivetotop - hyprctl dispatch focuswindow "address:${addr}" >/dev/null 2>&1 || exit 0 - exit 0 -fi - -if (( overflow == 0 )) || [[ "$layout" != "scrolling" ]]; then +# IMPORTANT: hide module by outputting NOTHING (no JSON) when not relevant +if (( overflow <= 0 )) || [[ "$layout" != "scrolling" ]]; then exit 0 fi