Is there a way to determine what state the Mac's screen is in? I'd like to have a script that checks if the screen is in a non-active state; so either the screen saver is running or the display is asleep. Can this even be done via applescript?

I'm trying to make a script similar to these proximity detection scripts, except I want them to activate when I've either manually activated the screensaver, put the display to sleep or when the system activates the time based screensaver and display sleep settings.

link|improve this question
feedback

1 Answer

Yes, with this code:

set display_sleep_state to do shell script "ioreg -n IODisplayWrangler |grep -i IOPowerManagement"
if display_sleep_state contains sleeping then
   -- Display is asleep
else if display_sleep_state contains awake then
   -- Display is awake
else
   -- We don't know.
end if
link|improve this answer
Doing all the work using do shell script hardly qualifies as yes ;-) – Daniel Beck Mar 26 '11 at 16:27
@DanielBeck: Why? It solves the problem, doesn't it? – Wuffers Mar 26 '11 at 16:30
I upvoted because of that -- I referred to this being an AppleScript solution. – Daniel Beck Mar 26 '11 at 16:42
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.