28 lines
673 B
Bash
28 lines
673 B
Bash
#!/usr/bin/env bash
|
|
|
|
# Get active workspace ID
|
|
active_ws=$(hyprctl activeworkspace -j | jq -r '.id')
|
|
|
|
# Get clients in active workspace
|
|
clients=$(hyprctl clients -j | jq -r \
|
|
".[] | select(.workspace.id==$active_ws) | .title")
|
|
|
|
# Count clients
|
|
count=$(echo "$clients" | grep -c .)
|
|
|
|
# If less than 2 clients → hide module
|
|
if [ "$count" -lt 2 ]; then
|
|
jq -c -n '{text:"", class:"hidden"}'
|
|
exit 0
|
|
fi
|
|
|
|
# Build tooltip (newline separated)
|
|
tooltip=$(echo "$clients" | sed 's/^/• /' | paste -sd '\n' -)
|
|
|
|
# Output JSON with dash
|
|
jq -c -n \
|
|
--arg text "-$count" \
|
|
--arg tooltip "$tooltip" \
|
|
--arg class "active" \
|
|
'{text:$text, tooltip:$tooltip, class:$class}'
|