Saying how many hours of battery are left?

Is there a way to say how many hours and minutes of battery are left and if my mac is charging, how long until it is fully charged?

Model: MacBook Pro
AppleScript: 2.1.2
Browser: Google Chrome 5.0.342.9
Operating System: Mac OS X (10.6)

Hi,

you can read the parameters with

do shell script "pmset -g batt"

Thanks for that, using that shell script I know how to like display a dialog box saying whether my mac’s charging or not but I’m not sure how to also add percent of battery left and how long til it’s fully charged/ runs out, I’m not to great at Applescript…

Something like this (bearing in mind that the fraction is decimal, not minutes)

set state to paragraph 2 of (do shell script "pmset -g batt")
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ";"
set tParts to text items of state
set AppleScript's text item delimiters to tid
if item 2 of tParts = " discharging" then
	say item 3 of tParts
end if

Thanks :slight_smile: I think I’ve managed to do it myself now, after working on it for a while :smiley: . I used those text item delimiters, but I’m not sure how efficient my code is; I’ve never actually used them before.