set volume output volume 100 without output muted
2. Open/Kill your application based on day and time
Script to get set the day of the week to variable today
set today to weekday of (current date)
Script to get the time, takes current time and sets it to variable whichHour
set todayTime to time of (current date)
set whichHour to (todayTime / (60 * 60))
A possible cleaner way, sets currents current time to whichHour
set whichHour to ((time of (current date)) / (60 * 60))
We now have the current hour to the variable ‘whichHour’ to the and the day of the week to ‘today’.
3. Create functions to start the application and stop the application.
Let’s say the application I want to control is called ‘Sandra_Sound’.
When runApp() is called, it checks if the application ‘Sandra_Sound’ is already open and if not open, then opens the application. When killApp() is called, it checks if the application ‘Sandra_Sound’ is running AND quits the application is it’s open.
4. When you want your application up and running
Essentially the day of the week and time are the most important for me. So say, the museum is open on Tuesdays-Fridays, 10am-5pm. Also, Saturdays, 11am-5pm. All the other days, I don’t want anything to happen.
Notice where I have commented out “# return 3600”, we will discuss the importance of using a return later in the Handler section.
5. Set this all in on an idle Handler
We are going to wrap the timing logic with an idle Handler. Your computer will execute the contents of an on Idle handler when idle, typically every 30 seconds, unless the code returns a different value (or the last result). So there may be reasons you would want the on Idle script to wait a longer/shorter duration before executing again. For example if the day is Sunday, and you know your application doesn’t need to start for another 24 hours — you really don’t need to check every 30 seconds which day it is, so you can set the return value higher to something like an hour (3600 seconds). For more information on Handlers, use this [ reference ].
6. Putting it all together
Now, at default, this script will run every 30 seconds, to check the day and time. Change the last return value if you want then on idle script to execute more/less often.
7. Make sure your computer runs this script on boot.
In OS X, make sure your mac opens the script on boot.
Users & Groups > Login Items > + > Your script name
8. Make sure your computer automatically logins under your user name and restarts after power failure.
To make sure your computer logins in under your username.
System Preferences > Users & Groups > Login Options > Automatic login > Your User Name
If you don’t see your current user name in the dropdown menu, you are probably using your AppleID & Password to login. You have to unlink your login from your AppleID.
System Preferences > Users & Groups > Current Users > Your User Name > Change Password > Use Separate Password
After you’ve change your password, you should be able see your user name in the Automatic login dropdown menu.
To make your computer restart after power failure (say your MacMini gets it’s power turned off and on quickly).
System Preferences > Energy Saver > Restart after power failure
That’s it, hope this helps.