How to tell total MacBook screen on time on battery?

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.


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}'

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.