Skip to content

Instantly share code, notes, and snippets.

@hjdarnel
Created August 21, 2018 19:29
Show Gist options
  • Save hjdarnel/35bb0dbb72b481cdb2f2b253288a0e69 to your computer and use it in GitHub Desktop.
Save hjdarnel/35bb0dbb72b481cdb2f2b253288a0e69 to your computer and use it in GitHub Desktop.
do shell script "pmset -g batt | grep InternalBattery | column -t"
set x to the result
set percentage to word 6 of x
set state to word 7 of x
set t1 to word 8 of x
set t2 to word 9 of x
set remaining to the word 10 of x
if remaining contains "remaining" then
if state is "discharging" then
return percentage & "%"
else if state is "charging" then
return percentage & "% | " & "charging"
else
return percentage & "% | charged"
end if
else
return percentage & "% | " & "calculating"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment