#!/bin/bash
#c_ws=$(	hyprctl activeworkspace | grep "workspace ID" | awk '{print $3}' | head -1)
#l_ws=""

#while true; do
#	if [[ "$c_ws" != "$l_ws" ]]; then
#			echo $c_ws
#	    l_ws=$c_ws
#	fi
#done

#prev_value_ws=""
#while true; do
#  current_value_ws=$(hyprctl activeworkspace | grep "workspace ID" | awk '{print $3}' | head -1)  
#  if [[ "$current_value_ws" != "$prev_value_ws" ]]; then
#    echo "$current_value_ws"
#    prev_value_ws="$current_value_ws"
#  fi
#done

#prev_value_tl=""
#while true; do
#	current_value_tl=$(hyprctl activewindow | grep title | awk 'NR == 2' | awk '{print $2}')
#	if [[ "$current_value_tl" != "$prev_value_tl" ]]; then
#    echo "$current_value_tl"
#   prev_value_ws="$current_value_tl"
#  fi
#done


prev_ws=""
prev_tl=""
output_file="/home/fox/.cache/waybar_output"

while true; do
  current_ws=$(hyprctl activeworkspace | grep "workspace ID" | awk '{print $3}' | head -n1)
  current_tl=$(hyprctl activewindow | grep -A1 "title" | tail -n1 | awk '{$1=""; print substr($0, 2)}')

  if [[ "$current_ws" != "$prev_ws" || "$current_tl" != "$prev_tl" ]]; then
    echo "$current_ws"
		echo "$current_tl"
    prev_ws="$current_ws"
    prev_tl="$current_tl"
  fi

  sleep 0.1
done
