Last active
November 10, 2019 02:29
-
-
Save youandhubris/9bd9ff75a7e97a34a1f8f46448b686ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TO DO | |
# https://superuser.com/questions/688024/how-can-i-determine-if-an-application-is-not-responding | |
# Check For Process With Schedule | |
# File > Export | |
# File format: Application | |
# Options: Stay open after run handler | |
# Notes | |
# Words like 'path' are reserved. | |
# To designate them as variables you surround them with || | |
global checkList, wakeHour, sleepHour | |
on run | |
#Declarations | |
set calculator to {process:"Calculator", |path|:"Stuff:Applications:Calculator"} | |
set calendar to {process:"Calendar", |path|:"Stuff:Applications:Calendar"} | |
set checkList to {calculator, calendar} | |
set wakeHour to 9 | |
set sleepHour to 21 | |
#Logic | |
delay 5 | |
tell application "Finder" | |
set bootApp to |path| of (item 1 of checkList) | |
open file bootApp | |
end tell | |
end run | |
on idle | |
delay 5 | |
set hoursNow to hours of (get current date) | |
if (hoursNow > wakeHour) and (hoursNow < sleepHour) then | |
tell application "Finder" | |
repeat with checkItem in checkList | |
if not (process (|process| of checkItem) exists) then | |
open file (|path| of checkItem) | |
end if | |
delay 5 | |
end repeat | |
end tell | |
end if | |
return 1 | |
end idle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment