Using Applescript to Sleep Computer
Power Manager - Mac automation and energy saving software for Mac OS X
Download a free demonstration of Power Manager today and start saving.
DssW > Sleep Centre >
Jackie Jones - 10 October 2008
In OS 10.4.11, I used this simple script to sleep the computer:
tell application "Finder" to sleep
In OS 10.5.5, this script has a long delay before the computer sleeps. Is there a better way to script sleep?
Daniel Schaffner - 22 October 2008
I tell it application "System Events". also run 10.5.5 and have no delay.
I use this:
--pmset changes and reads power management settings such as idle sleep timing wake on administrative access automatic restart on power loss, etc.
set current_mode to do shell script "pmset -g | grep mode" --look for current hibernate mode
if current_mode contains "3" then set the current_name to "sleep" if current_mode contains "1" then set the current_name to "safe sleep"
display dialog "I'm in " & current_name & " mode. Set new mode!" buttons {"sleep", "safe sleep", "cancel"} default button 3 set new_name to button returned of result
if new_name is "sleep" then set new_mode to "3" if new_name is "safe sleep" then set new_mode to "1"
do shell script "pmset -a hibernatemode " & new_mode with administrator privileges
display dialog "Go to " & new_name & " now?" buttons {"yes", "no"} default button 2
if button returned of result is "yes" then tell application "System Events" to sleep
Download a free demonstration of Power Manager today and start saving.
Welcome to DssW. We make saving energy software for Mac OS X.
Power Manager can help you save you time, energy, and money. With Power Manager you can:
Download a free demonstration of Power Manager today and start saving.
sleep from terminal“is there a built-in shell command to make the computer sleep from terminal?” 32 messages — Last update 4 January 2006
|
"Sleep" over network“Is there a way to tell my Mac to go to sleep without having physical access to it?” 7 messages — Last update 8 July 2003
|
[ANN] Power Manager 3.5 - Reduce Your Mac's Energy Costs“The new version of Power Manager makes energy saving easy.” 24 messages — Last update 12 January 2007
|
use and privacy policies - support@dssw.co.uk - http://www.dssw.co.uk
Dragon Systems Software Limited, 3rd Floor Suite, 41-43 Broad Street, Hereford, HR4 9AR, United Kingdom
Copyright © 1997 — 2010 Dragon Systems Software Limited (DssW). All rights reserved.