28 lines
684 B
Bash
28 lines
684 B
Bash
#!/usr/bin/env bash
|
|
|
|
# Get the focused monitor's active workspace
|
|
focused_ws=$(hyprctl activeworkspace -j | jq -r '.id')
|
|
|
|
# Get clients in focused workspace
|
|
clients=$(hyprctl clients -j | jq -r \
|
|
".[] | select(.workspace.id==$focused_ws) | \"\(.title)\"")
|
|
|
|
# Count clients (only non-empty lines)
|
|
count=$(echo "$clients" | grep -c '\S')
|
|
|
|
# If no clients → hide module
|
|
if [ "$count" -eq 0 ]; then
|
|
jq -c -n '{text:"", class:"hidden"}'
|
|
exit 0
|
|
fi
|
|
|
|
# Build tooltip
|
|
tooltip=$(echo "$clients" | sed 's/^/• /' | paste -sd '\n' -)
|
|
|
|
# Output JSON
|
|
jq -c -n \
|
|
--arg text "$count" \
|
|
--arg tooltip "$tooltip" \
|
|
--arg class "active" \
|
|
'{text:$text, tooltip:$tooltip, class:$class}'
|