Created
August 21, 2018 19:29
-
-
Save hjdarnel/35bb0dbb72b481cdb2f2b253288a0e69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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