Created
March 13, 2022 21:28
-
-
Save semicolonsnet/ac2dc9050f55a531fcd08cc129e69849 to your computer and use it in GitHub Desktop.
Returns a non-zero error code if a macOS machine is asleep. Useful because Macs respond to pings when asleep, so you may need an alternative test.
This file contains 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
#!/bin/bash | |
if [[ $(pmset -g powerstate | grep -E 'AppleDisplay') == "AppleDisplay 3 3 USEABLE" ]] | |
then | |
exit 0 | |
else | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment