Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-12-2017, 11:02 AM   #1
LQ Newbie
Registered: Aug 2017
Location: Mexico
Distribution: Ubuntu 14.04, OS X High Sierra,
Posts: 16

Rep: Reputation: Disabled
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.
Old 10-14-2017, 05:12 AM   #2
LQ Addict
Registered: Dec 2013
Posts: 8,745
Blog Entries: 5

Rep: Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141Reputation: 2141
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)
1 members found this post helpful.
Old 10-25-2017, 09:45 AM   #3
LQ Newbie
Registered: Aug 2017
Location: Mexico
Distribution: Ubuntu 14.04, OS X High Sierra,
Posts: 16

Original Poster
Rep: Reputation: Disabled

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!


linux, mac, python, system-monitor

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
powered USB hubs: what do I need the power supply for? newbiesforever General 3 04-19-2016 12:49 AM
[SOLVED] Laptop screen not switching back on when powered down by power manager. george-lappies Slackware 15 05-27-2011 05:06 PM
How to Power-Off with Button? win32sux Linux - Hardware 6 07-01-2006 01:19 PM
Needs to push power button to power off? danpin Linux - Newbie 5 10-21-2003 08:08 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration