Last Updated: February 25, 2016
·
516
· mustaphayork

OS X in-terminal battery notification script.

A simple notification script for your laptop battery:

ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'
ioreg -n AppleSmartBattery -r | awk '$1~/ExternalConnected/{gsub("Yes", "+");gsub("No", "-"); print substr($0, length, 1)}'