#!/bin/bash
#statecon=$(eww state | xargs)
#echo $statecon
#if [[ -z  `echo $statecon` ]] ;then
#    ~/Dotfiles/desktopenvs/hyprland/scripts/monitorhandler.sh
#else
#    eww close-all
#fi
GTK_THEME=cyberqueer

monitorsum=$(hyprctl monitors | grep ID | wc -l)

actmon=$(hyprctl monitors | grep -B12 "focused: yes" | head -n1 | cut -d'(' -f 2 | cut -d' ' -f 2 | cut -d')' -f 1)
statecon=$(eww active-windows | grep "bar$actmon")
#notify-send $statecon
if [ "$statecon" != '' ]; then

    for i in $(seq 1 $monitorsum);
    do
	declare -i curmon=$i-1
	echo $actmon $curmon
	if [ "$curmon" == "$actmon" ]; then
	    /usr/bin/eww open --toggle bar$curmon
	fi
    done

else
    
    for i in $(seq 1 $monitorsum);
    do
	declare -i curmon=$i-1
	if [ "$curmon" == "$actmon" ]; then
	    /usr/bin/eww open bar --id bar$curmon --arg monitor=$curmon
	fi
    done

fi



