Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

b0fh666

macrumors 6502a
Original poster
Oct 12, 2012
954
785
south
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
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
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.
 

b0fh666

macrumors 6502a
Original poster
Oct 12, 2012
954
785
south
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.