I've been toying around with AppleScript and Automator to get this thing to work, but I just can't seem wrap my head around it. If anyone could show me an example or give me some tips on how I can set an application to close at a specific time and then put the computer to sleep or shutdown, it would be greatly appreciated.
|
I'm assuming that you'd like to initiate this procedure as opposed to having it run at a regularly scheduled time. My approach would be to initiate this from the command line, but any commands can be run in a shell script component of an Automator script with some modification. The following approach combines a few components to get the job done:
1. Telling the Application to quit This can be as simple as:
2. Putting the computer to sleep Have a look at
3. Scheduling an operation to be run at a specific time Have a look at the at command. This command gives you the ability to specify a time for a command to run. You'll need to enable this functionality as it is not by default. To enable the
Once you've enabled
which works because
Putting it all together What follows assumes that
Save that file to
Caveats I didn't do any checking to make sure that Mail actually closed. The script also assumes that nothing else is going to get in the way of putting the computer to sleep. I've kept it simple here as a starting point for what you want. |
||||
|
|
atisn't what you want.cronorlaunchd. If you want an easier interface to setting that up, maybe lingon 3 will help. – ephsmith Aug 12 '12 at 12:33