Skip to content

Delayed Sleep With AppleScript

I've been complaining about not being able to put the mac to sleep with a mouse. Well, Lauri came up with a solution. According to his concept (great work!) I created this AppleScript, which puts your mac to sleep after 10 seconds (unless you cancel it):

# time in seconds to delay before sleep
set delay_time to 10

display dialog ¬
	"Going to sleep in " & delay_time & ¬
	" seconds" buttons {"Cancel"} ¬
	giving up after delay_time ¬
	default button 1
copy the result as list to {buttonpressed}
if the buttonpressed is not "Cancel" then
	tell application "Finder" to sleep
end if

You can create the AppleScript yourself or download an AppleScript application: Delayed-Sleep.app (60 kB), for Intel (newer macs), for PPC (older ones).