Last active
August 28, 2020 08:15
-
-
Save ts1/dade56c2ef6d89f034f82f2e2d149003 to your computer and use it in GitHub Desktop.
Tiny command to detect whether Mac display is awake or asleep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <CoreGraphics/CoreGraphics.h> | |
| int main() | |
| { | |
| return CGDisplayIsAsleep(CGMainDisplayID()); | |
| } |
Use in AppleScript
try
do shell script "/path/to/awake"
-- display is awake
on error
-- display is asleep
end try
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile like this