I have this chunk of code:
on run
delay 10
set lidState to do shell script "ioreg -r -k AppleClamshellState | awk -F \" = \" '/AppleClamshellState/ {print $2}'"
if lidState = "Yes" then
tell application "Finder" to sleep
end if
end run
What I want it to do (at least for the first step) is to wait 10 seconds, and then sleep my computer if my lid is closed by the end of those 10 seconds. Is my script right, or am I missing something?
say
command, e.gsay "going to sleep"
in the script in theif
block so you can hear if it triggers. Do you hear it say?if
thing... Maybe it's me sayingFinder
instead ofcomputer
or something else?tell application "Finder" to sleep
is proper. If it's triggering and not actually sleeping, then something is either intercepting the call or blocking the system from sleeping. Have your reviewed thesystem.log
for any clues?