#!/bin/bash
cocoadialog='/usr/local/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog'
cd ~/Desktop
cd VisiCutMaterialDb
echo "Checking Camera..."
if ./snap > /dev/null
then
	echo "Nothing" > /dev/null
else
	$cocoadialog msgbox --icon x --informative-text "Please make sure that the camera is plugged in via USB (short cable) and no other application is occupying it" --text "Camera doesn't work" --button1 OK
	exit
fi
cd ../
{
cd VisiCutWithCam.app/Contents/MacOS
./server.sh
}&
PID=$!
echo "PID is $PID"
$cocoadialog bubble --title "VisiCut ZingCAM" --text "Found Camera.Starting VisiCut and waiting until it is finished"&
open -W VisiCut.app
$cocoadialog bubble --title "VisiCut ZingCAM" --text "VisiCut has stopped.Exiting..."&
echo "killing $PID"
kill $PID
