Had to make some adjusttments

This commit is contained in:
2026-02-27 17:46:15 +01:00
parent 31fe8b8d0e
commit b6497c1e0c
3 changed files with 15 additions and 13 deletions
@@ -4,46 +4,46 @@ set -euo pipefail
COLUMN_WIDTH="${COLUMN_WIDTH:-0.5}"
ICON="${ICON:-󰓒}"
# Always output valid JSON, even on error
fail_json() {
printf '{"text":"%s !","tooltip":"hyprscroll-overflow: %s","class":"error"}\n' "$ICON" "${1//\"/\\\"}"
printf '{"text":"%s !","tooltip":"hyprscroll-overflow: %s","class":"error"}\n' \
"$ICON" "${1//\"/\\\"}"
exit 0
}
command -v hyprctl >/dev/null 2>&1 || fail_json "hyprctl not in PATH"
command -v jq >/dev/null 2>&1 || fail_json "jq not in PATH"
# Focused monitor id + its active workspace id (both numeric)
read -r focused_mon_id focused_ws_id < <(
hyprctl -j monitors 2>/dev/null | jq -r '
.[] | select(.focused==true) | "\(.id) \(.activeWorkspace.id)"
' 2>/dev/null
'
) || fail_json "failed to read monitors"
[[ -n "${focused_mon_id:-}" && -n "${focused_ws_id:-}" ]] || fail_json "no focused monitor?"
# Count mapped windows on that monitor+workspace
win_count="$(
hyprctl -j clients 2>/dev/null | jq --argjson ws it should only respond with a"$focused_ws_id" --argjson mid "$focused_mon_id" '
hyprctl -j clients 2>/dev/null | jq --argjson ws "$focused_ws_id" --argjson mid "$focused_mon_id" '
[ .[]
| select(.mapped == true)
| select(.workspace.id == $ws)
| select(.monitor == $mid)
] | length
' 2>/dev/null
'
)" || fail_json "failed to count clients"
# floor(1 / COLUMN_WIDTH)
max_visible="$(awk -v w="$COLUMN_WIDTH" 'BEGIN{ if (w<=0) {print 1} else {print int(1.0/w)} }')" || fail_json "awk failed"
max_visible="$(awk -v w="$COLUMN_WIDTH" 'BEGIN{ if (w<=0) {print 1} else {print int(1.0/w)} }')" \
|| fail_json "awk failed"
(( max_visible < 1 )) && max_visible=1
overflow=$(( win_count - max_visible ))
layout="$(hyprctl getoption general:layout 2>/dev/null | awk '/str:/ {print $2; exit}')"
[[ -n "${layout:-}" ]] || layout=""
if (( overflow > 0 )) && [[ "$layout" == "scrolling" ]]; then
printf '{"text":"%s +%d","tooltip":"%d windows; approx %d fit (column_width=%s)","class":"overflow"}\n' \
"$ICON" "$overflow" "$win_count" "$max_visible" "$COLUMN_WIDTH"
else
printf '{"text":"","class":"hidden"}\n'
fi
# truly empty (and tooltip empty) + class for CSS
printf '{"text":"","tooltip":"","class":"hidden"}\n'
fi
@@ -40,7 +40,8 @@
"exec": "bash -lc 'COLUMN_WIDTH=0.5 \"$HOME/.config/hypr/scripts/hyprscroll-overflow.sh\"'",
"return-type": "json",
"interval": 1,
"format": "{}",
"format": "{text}",
"tooltip": "{tooltip}",
},
"idle_inhibitor": {
@@ -81,7 +81,8 @@ window#waybar {
padding: 0;
margin: 0;
min-width: 0;
border: none;
border: 0;
background: transparent;
opacity: 0;
}