Power Status (was Re: Because LC can't do two things at once.)
Richard Gaskin
ambassador at fourthworld.com
Mon Mar 2 14:18:45 EST 2015
Peter Brigham wrote:
> What gets returned in
> get URL "/proc/acpi/battery/BAT1/state" on Unix?
> If you give me a sample to work with I will finish the handler and
> post it.
Further reading shows that path deprecated on many modern systems,
suggesting the /sys path instead:
/sys/class/power_supply/BAT0/
<https://blog.sleeplessbeastie.eu/2013/01/02/debian-how-to-monitor-battery-capacity/>
Of the elements found at that path "status" seems the most relevant, but
at the moment I'm on a desktop workstation and my Linux laptop is at
home so I can't check it right now.
The key question for the moment is whether BAT0 or BAT1 is used by folks
here. Oddly enough when I was using /proc I had no BAT0 but I did find
the info in BAT1.
Perhaps my Dell model thinks it can support multiple batteries (maybe
counting the onboard clock battery? Seems unlikely).
Once we discover the battery numbering scheme, parsing the byte stream
at that location will be trivial.
In fact, the articles I've found suggest that when that status element
is present it contains just a single word, such as "charging" or
"discharging", shown in the example here:
<https://bbs.archlinux.org/viewtopic.php?id=133716>
I'll see if I can get some time to look into this further this evening.
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list