Created
September 5, 2018 02:16
-
-
Save jdbrice/eaf19c94f7562d41fff932c43b3c7510 to your computer and use it in GitHub Desktop.
battery widget applescript for better touch tools
This file contains hidden or 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
set theList to paragraphs of text of (do shell script "pmset -g batt") | |
set percent to word 6 of theList's item 2 | |
set charge to word 7 of theList's item 2 | |
if (charge = "charging") then | |
set iconC to "⚡️" | |
else | |
set iconC to "" | |
end if | |
set remainingRaw to my split(theList's item 2, " ") | |
set remainingTime to remainingRaw's item 5 | |
if (remainingTime = "(no") then | |
set strTime to " (?)" | |
else if (remainingTime = "0:00") then | |
set strTime to "" | |
else | |
set strTime to " (" & remainingTime & ")" | |
end if | |
return iconC & percent & "%" & strTime | |
to split(someText, delimiter) | |
set AppleScript's text item delimiters to delimiter | |
set someText to someText's text items | |
set AppleScript's text item delimiters to {""} | |
return someText | |
end split |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment