How do I check whether the screen is off due to the Energy Saver settings in System Preferences under Mac/Python?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quick and dirty solution: call
ioregand parse the output.In my computer, the value for
CurrentPowerStateis4when the screen is on and1when the screen is off.Better solution: use
ctypesto get that information directly fromIOKit.