hyprland-eww/bar/workspace.sh
2024-06-24 01:47:04 +09:00

29 lines
887 B
Bash

#!/bin/sh
monitor_id=$1
print_workspaces() {
buf=""
output=$(hyprctl -j workspaces | jq -r ".[] | select(.monitorID == $monitor_id)")
focused=$(hyprctl monitors -j | jq -r ".[] | select(.id == $monitor_id) | .activeWorkspace.id")
for w in $(echo $output | jq -r '.id'); do
text=$(echo $output | jq -r "select(.id == $w) | .name")
if [ $w -eq $focused ]; then
buf="$buf (label :class \"workspace focused\" :text \"$text\")"
else
buf="$buf (label :class \"workspace\" :text \"$text\")"
fi
done
echo "(box :class \"workspaces\" :orientation \"h\" :valign \"start\"$buf)"
}
print_workspaces
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do
case $line in
workspace\>\>*)
echo $line
print_workspaces
;;
esac
done