Check battery status from the console?

Discussion in 'Mac Programming' started by rebby, Jan 25, 2011.

  1. rebby macrumors 6502

    Joined:
    Nov 19, 2008
    Location:
    MN
    #1
    Does anybody know of a way to check the battery status from the console on a Macbook? I'd like to create a cron job that will only execute if running on A/C power.

    I've done a few searches and have come up empty thus far. Thanks!
     
  2. rebby thread starter macrumors 6502

    Joined:
    Nov 19, 2008
    Location:
    MN
    #2
    Looks like I jumped the gun on this one. It's buried with-in ioreg ->

    Code:
    ioreg -l | awk '/ExternalConnected/ {print $5}'
    Will output "Yes" if external power is connected, "No" otherwise.
     

Share This Page