#!/bin/env sh

# From: https://wiki.hyprland.org/Useful-Utilities/Status-Bars/#eww

# TODO: add `first` attribute indicating if workspace is the first on its screen
spaces (){
	ACTIVE_ID=$(hyprctl activeworkspace -j | jq -Mc ".id")
	hyprctl workspaces -j | jq -Mc "map({id, name, monitor, active: [.id == $ACTIVE_ID][0]}) | sort_by(.id)"
}

spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
	spaces
done
