LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to know if a Mac has been powered on by the power button? (https://www.linuxquestions.org/questions/programming-9/how-to-know-if-a-mac-has-been-powered-on-by-the-power-button-4175615532/)

xedge 10-12-2017 11:02 AM

How to know if a Mac has been powered on by the power button?
 
Hello everyone!

I'm developing a MacOs Application in python and I'm having some issues trying to find information related to the power button pressed event. I know that in Ubuntu 14.04 you can find information about it on the acpi folders, but I realized that here in Mac that process is supposedly managed by powerd, I was looking thru the dmesg and console logs looking for something that changes when a restart is done automatically or if the computer couldn't restart itself and had to be powered on by the button.

Let me explain a little more.

In the application, I have a config file where I keep record of how many restarts have been done on the Mac by another application developed by Apple called RestartX. When it hits 10 restarts it will stop with an automation script on Sikuli. The thing is that when the test fails, the computer MUST be turned on by the user, and the RestartX app doesn't record if the test fails as it registers that operation as a Restart (which adds 1 to the app restart counter) and not as a PowerOn event.

If someone with more programming experience could tell me where to catch this kind of events apart from dmesg or how to tell which event in dmesg is related to powerEvents I will be very grateful.

ondoho 10-14-2017 05:12 AM

this has been in zero-reply long enough.

i suggest you try the other way round:
how to know if the machine has been rebooted automatically?
(and then assuming that everything else is a manual boot)

xedge 10-25-2017 09:45 AM

Thanks!
 
Really appreciate your help! I have done some research on that subject but I may be doing it in the wrong way, thanks again, I will do as you suggest!


All times are GMT -5. The time now is 04:44 AM.