36 lines
972 B
Bash
Executable File
36 lines
972 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# {{{autogen}}}
|
|
# Get focused monitor name
|
|
focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused==true) | .name')
|
|
monitor="${WAYBAR_OUTPUT_NAME:-$focused_monitor}"
|
|
|
|
# Hide if not focused monitor
|
|
if [ "$monitor" != "$focused_monitor" ]; then
|
|
jq -c -n '{text:"", class:"hidden"}'
|
|
exit 0
|
|
fi
|
|
|
|
# Get active workspace on this monitor
|
|
active_ws=$(hyprctl monitors -j | jq -r \
|
|
".[] | select(.name==\"$monitor\") | .activeWorkspace.id")
|
|
|
|
# Get clients
|
|
clients=$(hyprctl clients -j | jq -r \
|
|
".[] | select(.workspace.id==$active_ws) | \"\(.title)\"")
|
|
|
|
count=$(echo "$clients" | grep -c '\S')
|
|
|
|
# Hide if 0 or 1 clients — no point showing window switcher
|
|
if [ "$count" -le 1 ]; then
|
|
jq -c -n '{text:"", class:"hidden"}'
|
|
exit 0
|
|
fi
|
|
|
|
tooltip=$(echo "$clients" | sed 's/^/• /' | paste -sd '\n' -)
|
|
|
|
jq -c -n \
|
|
--arg text "$count" \
|
|
--arg tooltip "$tooltip" \
|
|
--arg class "active" \
|
|
'{text:$text, tooltip:$tooltip, class:$class}'
|