30 lines
1.0 KiB
Bash
Executable File
30 lines
1.0 KiB
Bash
Executable File
#!/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 (button :class \"workspace focused\" :width 20 :height 20)"
|
|
else
|
|
buf="$buf (button :class \"workspace\" :width 20 :height 20)"
|
|
fi
|
|
done
|
|
focused=$(echo $output | jq -r "select(.id == $focused) | .name")
|
|
|
|
echo "(box :class \"workspaces\" :orientation \"h\" :space-evenly false :spacing 4 :hexpand true :valign \"center\"$buf (label :class \"label\" :text \"$focused\"))"
|
|
}
|
|
|
|
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 |