Power Status (was Re: Because LC can't do two things at once.)

Peter Brigham pmbrig at gmail.com
Thu Mar 5 13:03:11 EST 2015


So the Unix case should be:

         if there is a file "/sys/class/power_supply/BAT0/" then
            put url "/sys/class/power_supply/BAT0/" into tStatus
         else if is a file "/sys/class/power_supply/BAT1/" then
            put url "/sys/class/power_supply/BAT1/" into tStatus
         else
            return "no battery"
         end if
         put word 1 of tStatus into tStatus
         return
caseSwitch(tStatus,"discharging=Battery","charging,unknown,full=AC", \
               "=no battery","*=*")

Double-check me on this.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Thu, Mar 5, 2015 at 11:27 AM, Mark Wieder <mwieder at ahsoftware.net> wrote:

> Peter-
>
> Wednesday, March 4, 2015, 5:10:53 AM, you wrote:
>
> >> and what I see on my Thinkpad running linux Mint 17 is status returns
> one of
> >> three states:
> >>
> >> Unknown if the laptop is plugged into the AC adapter
> >> Discharging if running off the battery power
> >> Charging if it's (wait for it) charging the battery.
>
> > Please clarify: "Unknown" if using the AC adapter, and "Charging"
> > if it's charging the battery. How could you be charging the battery
> > if you're not using the AC adapter?
>
> > Is "Unknown" reserved for when you're plugged in and the battery is
> > fully charged?
>
> Yes. The battery is in place but neither charging nor discharging. I
> do see that the "Unknown" description is ambiguous there.
>
> >> If I remove the battery and run the laptop off AC power there is no BAT0
> >> directory.
>
> > OK, so a test for "no such file" is called for.
>
> Yes, there are four possible states. And then I guess in Richard's
> case you'd also have to check for BAT1.
>
> --
> -Mark Wieder
>  ahsoftware at gmail.com
>
> This communication may be unlawfully collected and stored by the National
> Security Agency (NSA) in secret. The parties to this email do not
> consent to the retrieving or storing of this communication and any
> related metadata, as well as printing, copying, re-transmitting,
> disseminating, or otherwise using it. If you believe you have received
> this communication in error, please delete it immediately.
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list