#!/bin/bash # Get all workspaces # Using hyprctl JSON output workspaces=$(hyprctl workspaces -j) # Initialize output JSON json="[" index=0 for ws in $(echo "$workspaces" | jq -r '.[] | @base64'); do _jq() { echo "$ws" | base64 --decode | jq -r "$1" } ws_id=$(_jq '.id') ws_name=$(_jq '.name') # Get windows in this workspace windows=$(hyprctl clients -j | jq -r ".[] | select(.workspace.id==$ws_id) | \"\(.id): \(.title)\"") # Format tooltip: sequential numbering tooltip="" count=1 while read -r win; do tooltip+="$count. $win\n" count=$((count+1)) done <<< "$windows" # If no windows if [ -z "$tooltip" ]; then tooltip="No windows" fi # Output JSON for Waybar json+=$(jq -n \ --arg name "$ws_name" \ --arg tooltip "$tooltip" \ '{text: $name, tooltip: $tooltip}') index=$((index+1)) [ $index -lt $(echo "$workspaces" | jq length) ] && json+="," done json+="]" echo "$json"