Regenerated

This commit is contained in:
2026-04-02 23:42:46 +02:00
parent cee2dd67b3
commit b5c97bf5fd
4 changed files with 338 additions and 399 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
"exec": "~/.config/waybar/scripts/hypr-workspaces.sh",
"interval": 2,
"return-type": "json",
"format": "{name}",
"format": "{text}",
"on-click": "~/.config/waybar/scripts/hypr-workspacesmenu.sh",
"tooltip": true
},
@@ -1,42 +1,25 @@
#!/bin/bash
#!/usr/bin/env bash
# Outputs JSON for Waybar showing workspace name + number of windows
# 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"
}
_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)\"")
# Count windows in this workspace
win_count=$(hyprctl clients -j | jq "[.[] | select(.workspace.id==$ws_id)] | length")
# 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
# Output JSON
json+=$(jq -n \
--arg name "$ws_name" \
--arg tooltip "$tooltip" \
'{text: $name, tooltip: $tooltip}')
--arg text "$ws_name ($win_count)" \
--arg tooltip "$(bash ~/.config/waybar/scripts/hypr-workspacesmenu.sh $ws_id)" \
'{text: $text, tooltip: $tooltip}')
index=$((index+1))
[ $index -lt $(echo "$workspaces" | jq length) ] && json+=","