10.6: Sleep computer via AppleScript

Apr 27, '10 07:30:00AM

Contributed by: tobyvoss

Snow Leopard only hintI use a minimal AppleScript to sleep my computer after nn minutes of playing music through iTunes. After upgrading to 10.6, my older solutions (tell application "Finder" to sleep or tell application "System Events" to sleep) were ineffectual, so I searched for another solution, and came up with this:

do shell script "pmset sleepnow"
This seems like the only way to enter sleep mode after the password-required activation of display sleep (or the screensaver). Note that I've only tried this from an administrator account, where it works fine.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100424161727333