Battery info on macbook

Discussion in 'Mac Programming' started by charclo, Aug 25, 2010.

  1. charclo macrumors newbie

    Joined:
    Aug 25, 2010
    #1
    Hi,

    Does anybody know how to get info on the battery of a macbook in python or PyObj? Or maybe ObjC so I can wrap it in python?
    I need the battery percentage and if the battery is charging, discharging or charged.

    I can do
    Code:
    import subprocess
    
    process = subprocess.Popen(['pmset', '-g', 'pslog'], shell=False, stdout=subprocess.PIPE)
    print process.stdout.readline()
    but I'm looking for something more pythonic

    Thanks,
    Charclo
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    If you can call C functions, then look at IOKit's IOPowerSources.
     

Share This Page