AppleScript to indicate battery status

macOS & Mac Apps

I've made this apple script and share the code with you here to be sure there is nothing that causes security issues.
• indicate battery level
• Indicate whether battery is charging, fully charged or discharging.
How to use it?!
1. Download the script file or copy the code below. If you download the file continue from step 4.
2. If you copied the code, open Apple script editor by searching for "Script" on spotlight.
3. paste the code and save the file in a directory you could easily reach.
4. Open Voiceover utilities>commanders>keyboard.
5. Click add new commander. I personally prefer choosing the letter 'b'.
6. From the commands menu choose from, select custom commands> Run AppleScript Script …
7. Get to the place of script and select it.

Hope that helps,
Mohamed E. Fayed

Google drive for the script file:…

This is the code (I may update it later to use "pmset" command only once):
set cmd to "/usr/bin/pmset -g batt | grep -Eo '[0-9]{2,3}%'"
set batteryLevel to (do shell script cmd)
set cmd to "/usr/bin/pmset -g batt | grep -Eo '(charged)|(charging)|(discharging)'"
set batteryStatus to (do shell script cmd)
if batteryStatus = "charged" then
set batteryStatus to "fully charged"
end if
set message to batteryLevel & ", " & batteryStatus
tell application "VoiceOver" to output message