#!/usr/bin/perl

########################################################
my $DISPLAYALERT		= $ARGV[0] . "/Contents/Resources/Alert.app/Contents/MacOS/Alert";
my $SYSTEM_VERS			= "/System/Library/CoreServices/SystemVersion.plist";
########################################################

DO_CHECKS: 
{
		########################################################
		# App must not be running
		my $APP					= "LEGO Digital Designer\.app";
		my $APP_IS_RUNNING 		= 0;
		my $RUNNING_ERROR		= "AppRunning";

		########################################################
		system ("/usr/bin/killall","-dc","LEGO Digital Designer");
		$KILLALL_RETURN  = $? >> 8;
		
		while ($KILLALL_RETURN == 0) {
				$ENV{'ALERT_APP_ACTION'} = $RUNNING_ERROR;
				system($DISPLAYALERT,"");
				# per nat torkington
		
				$KILLALL_RETURN = 0;
				system ("/usr/bin/killall","-dc","LEGO Digital Designer");
				$KILLALL_RETURN  = $? >> 8;	
		} # while app is running, stay stuck here
}

exit(0);

########################################################

