You’re at work, with no remote control access/capability to your Mac at home, brown-outs are occurring, and you forgot to plug it into a power strip due to some unknown reason last night. What do you do? Well, read on…
With some preparation, you can take advantage of Apple’s Mail‘s rules feature to run an AppleScript on a filtered message next time. Here’s how:
- Type this script using the Script Editor:
- Save the file somewhere. I suggest Documents/Scripts (create the folder if it doesn’t exist and start saving all your useful scripts in here).
- Open up Apple Mail and navigate to Preferences > Rules > Add Rules.
- Copy and setup the following rules based on the screenshot below:
- Apply the changes and minimize Apple Mail.
- That’s it! All you have to do now is send yourself an e-mail with “Sleep My Mac” as the subject with the message of “Go to sleep” from anywhere.
tell application “Finder”
display dialog “This computer will go to sleep in 1 minute.” buttons {“Sleep”, “Cancel”} default button 2 giving up after 60
sleep
end tell
Fig. 1.1 – Apple Mail’s Add Rule window
One caveat: For this to work, Apple Mail will need to be running (minimized is fine).
Hopefully, you find this tip helpful and empowering. Now back to work! =0)