quick system configuration question

Discussion in 'Mac Programming' started by b0fh666, Jan 2, 2015.

  1. b0fh666 macrumors 6502a

    b0fh666

    Joined:
    Oct 12, 2012
    Location:
    south
    #1
    hi all

    I have a small prog that used to check

    State:/IOKit/PowerSources/InternalBattery-0

    to see if the computer was running on AC or battery.
    that worked well until mavericks, but not on Yosemite... and I am having trouble finding where this bugger went.

    scutil list gives me just this :

    subKey [54] = State:/IOKit/LowBatteryWarning
    subKey [55] = State:/IOKit/Power/CPUPower
    subKey [56] = State:/IOKit/PowerAdapter
    subKey [57] = State:/IOKit/PowerManagement/CurrentSettings
    subKey [58] = State:/IOKit/PowerManagement/SystemLoad
    subKey [59] = State:/IOKit/PowerManagement/SystemLoad/Detailed
    subKey [60] = State:/IOKit/SystemPowerCapabilities

    SystemPowerCapabilities or PowerAdapter, perhaps?

    cheers
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    I'm unsure what programming language you're using. It seems to be shell command line tools, because you mentioned 'scutil', but there's also a framework underlying that command, and there's IOKit itself.

    If you're looking for a replacement for a command-line tool, try this:
    Code:
    pmset -g ps
    It should output the current power source, and may give some other data. I can only tell you what the output is on Mountain Lion, as none of my computers currently runs Yosemite or Mavericks. If you need help understanding the output, copy and paste it into CODE tags in a reply post.

    AFAIK, the power source info is the first (or only) line, so pipe it to the 'head' command to select just the 1st line, and maybe the 'grep' command to look for a specific word. If you need specific command-lines and options, ask again.
     
  3. b0fh666 thread starter macrumors 6502a

    b0fh666

    Joined:
    Oct 12, 2012
    Location:
    south
    #3
    its a cocoa/objective-c app, there's some voodoo called 'SCDynamicStoreRef' that reads the same stuff as scutil, but inside the program. it can even call some funcion when stuff changes, it seems (i'm a total n00b to osx programming / cocoa as I am an unwilling java drone for the last 7 years, and before that C++ on linux).

    invoking pmset or some external prog is a no-no.

    i'm leaning towards checking 'State:/IOKit/PowerAdapter' as it disappears and reappears as I plug/unplug the magsafe, so seems easy enough :)

    but it is LAME that appel removes the battery-0 key like that! :p

    cheers
     

Share This Page