💥 eww(bar/workspaces): fix workspace indicator with a literal script

This commit is contained in:
retrozinndev
2024-12-10 10:41:06 -03:00
parent 75ce9fa8f9
commit cacc59cb8e
41 changed files with 377 additions and 782 deletions
+29 -3
View File
@@ -1,11 +1,37 @@
#!/usr/bin/env bash
# display workspaces before checking for events
hyprctl -j workspaces | jq -c
#!/usr/bin/env bash
print_workspaces_literal() {
active_workspace_id=$(hyprctl -j activeworkspace | jq .id | xargs)
existing_workspaces=$(hyprctl -j workspaces | jq .[].id | xargs)
output="
(box :class \"workspaces\"
:space-evenly false
:orientation \"horizontal\""
for i in {1..10}; do
output=$output"
(button :onclick \"hyprctl dispatch workspace $i\"
:class { $active_workspace_id == $i ? \"active\" : \"\" }
:visible { \"$existing_workspaces\" =~ $i ? true : false }
\"\")"
if [ $i == 10 ]; then
output=$output")" # closes box if last
fi
done
echo "$(echo $output | xargs -0)"
}
# display workspaces on startup
print_workspaces_literal
handle() {
case $1 in
workspace* | destroyworkspace*) hyprctl -j workspaces | jq -c ;;
workspace*) print_workspaces_literal;;
esac
}