#!/bin/bash

echo "Waiting for screensharing to start "
osascript -e 'tell app "ScreenShare.tech" to quit'

osascript -e 'tell app "System Events" to display dialog "Waiting for tech" buttons "Disconnect and Quit" default button 1'

while true; do
   netstat -an | grep -q 127.0.0.1.5900 && break
   printf "."
   sleep 1
done
osascript -e 'tell app "System Events" to display dialog "Your tech has connected" buttons "Disconnect and Quit" default button 1'
echo "Tech Connected"

while netstat -an | grep -q 127.0.0.1.5900; do
   printf "x"
   sleep 1
done


osascript -e 'tell app "ScreenShare.tech" to quit'
