Battery testing, volume booster

Sarah Reichelt sarahr at genesearch.com.au
Tue Dec 7 17:51:36 EST 2004


Hi Richard,

> Looking for ideas on how to accomplish two functions from within Rev:
>
> 1. Read the status of the internal battery (i.e. % charged);
>
I can't help with the volume boost, but here is the script I use for 
reading the battery charge in an iBook. It requires the shell command 
"battery" which you can download from 
<http://www.mitt-eget.com/software/macosx/>. I couldn't get that link 
to work this morning, so if you want the shell command, let me know 
off-list and I can email you a copy.
I put it into the "/usr/bin/" folder but you can put it anywhere you 
like if you send the full path to the shell function. It can give you a 
whole heap of info - run it in Terminal and check the help, but the 
function below just returns the percent charge or "n/a" if there is no 
battery.


-- check battery level using OS X shell command
-- battery script needs to be in /usr/bin/
--
-- returns percent charge or "n/a"
--
function batteryLevel
   if isOSX() then
     put shell("battery csv") into tBatt
     put last item of line 1 of tBatt into tPercent
     put item 4 of tBatt into tFlags
     if char 6 of tFlags = 0 then
       -- no battery connected
       put "n/a" into tPercent
     end if
   else
     -- OS 9 can't use shell commands
     put "n/a" into tPercent
   end if
   return tPercent
end batteryLevel

Cheers,
Sarah



More information about the use-livecode mailing list