4

I'd like to know the total screen-on time since I plugged off my MacBook from the charger, but apparently there are no easily found stats for it.

Do I need an external app? I'm using MacBook Air 2015 with El Capitan.

2
  • This question is a duplicate. See the original. apple.stackexchange.com/questions/110780/… Oct 13, 2015 at 16:01
  • @JacoblovesRockstar there was already an answer here about that timer, but after my reply the person decided to remove it. The thing is, that shows the total uptime (including sleep), not screen on time.
    – user109107
    Oct 13, 2015 at 16:19

2 Answers 2

5
+100

I don't think that's something that Apple provides anywhere, however if you put in a little scripting work it's definitely doable. You can get the current brightness on the display with this command:

ioreg -l | awk '/ApplePanelRawBrightness/ {print $NF}'

A '0' result means the backlight is completely off. The upper limit depends on your specific hardware. You can get the highest possible number for your hardware with:

ioreg -l | awk '/AppleMaxBrightness/ {print $NF}'

You could set up a cron job to run that every minute, and record the result and current time, e.g. in a CSV file. You could then use a spreadsheet program to do the calculation. Or, you could use a higher level language like Python or Ruby to do the same thing and automate the calculation in your script. The latter would be my approach.

EDIT: I just noticed the 'on battery' part of the question - dunno how I managed to miss that. You can get a simple Yes or No answer to whether the AC adapter is connected using this command:

system_profiler SPPowerDataType |grep Connected | awk '{print $2}'
2
  • I would +1 you already, if my dazzling 6 total points allowed me to, but looks like you'll get the 100 points in 2 days anyway.
    – user109107
    Oct 13, 2015 at 16:41
  • And there you go.
    – user109107
    Oct 16, 2015 at 7:37
1

Go to Activity Monitor app on the Launchpad, then click on Energy tab. There, you will see the stats of your Mac's battery down below.

You must log in to answer this question.