Help. I’ve made an alarm in applescript, and I think it has become self-sustaining. Specifically, it activates itself whenever, not only on being invoked by iCal.
The alarm is intended to begin playing a specific playlist, increasing the volume gradually from 0 to 100. Five minutes in, it will give 5 warning beeps, after which a string of random characters is displayed in a dialog box, and you have to type them correctly within the time limit to turn of the alarm, or suffer an onslaught of beeps. You get another chance in 15 seconds, and the whole process quits after 30 minutes. The problem is, that’s not the end. The entire process starts up again on its own after some time, even if you end the iCal helper process directly.
Note: PLEASE manually edit the script’s parameters to maximize user comfort; this script, even if it were to work as intended, is designed to piss you off.
--ALARM VARIABLES: edit these to change the alarm's behavior --------------------------------
set sequenceTimer1 to 5 -- delay (in minutes) from start to "consciousness checker"
set sequenceTimer2 to 30 -- length (in minutes) of entire wakeup sequence
set maxVol to 15 -- maximum volume desired at an output volume of 100
set strLgn to 25 -- number of characters in test string
set waitTime to 25 -- time (in seconds) the user has to type test string
set beepTime to 15 -- time interval (in seconds) during which beeping will occur
---------------------------------------------------------------------------------------------------------------
set volume output volume 1
set theEnd1 to ((time of (current date)) + (sequenceTimer1 * 60))
set theEnd2 to ((time of (current date)) + (sequenceTimer2 * 60))
tell application "iTunes"
set sound volume to maxVol
play playlist "wakeup sequence"
end tell
repeat with i from 1 to 100
set volume output volume i
delay (1)
end repeat
delay (theEnd1 - (time of (current date)))
set aString to ""
repeat with i from 1 to strLgn
set aString to aString & (ASCII character (random number from 32 to 126))
end repeat
repeat with i from 1 to 5
beep
delay (1)
end repeat
set correct to false
repeat while correct is false and (time of (current date) ≤ theEnd2)
set anAnswer to text returned of (display dialog aString with title "Awake?" default answer "" buttons "OK" default button 1 giving up after waitTime)
if anAnswer = aString then
set correct to true
else
set correct to false
end if
if correct is true then
else
set annoy to ((time of (current date)) + beepTime)
repeat while time of (current date) ≤ annoy
beep
set volume output volume 100
end repeat
end if
end repeat