Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

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
share|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
    
The results I get from the first line have no mention of "sleep": "IOPowerManagement" = {"TimeSinceDeviceIdle"=5609187,"DevicePowerState"=4,"CurrentPowerState"=4,"Activ‌​ityTickles"=192146,"TimeSinceActivityTickle"=50,"IdleTi$ –  Billbad Feb 26 '13 at 1:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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