Skip to main content
AppleVis

Main navigation

  • Apps
  • Forum
  • Blog
    • Podcast
    • Guides
    • Hardware & Accessory Reviews
    • Bug Tracker
    • Developer Resources
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. macOS and Mac Apps

AppleScript to indicate battery status

By Mohamed Fayed, 21 January, 2020

Forum
macOS and 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.
Features:
• 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:
https://drive.google.com/drive/folders/1t97s1ThBzJxU6tVQiwN2sB1pmv8sekvp?usp=sharing

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

Options

  • Log in or register to post comments

More Like This

What has YouTube done with their design of the app and the latest version (Forum Topic)
Problems playing games with WINE (Forum Topic)
Announcing the release of a near professional quality recording of "Personal power, Second edition" by Michael Feir (Forum Topic)
Making VoiceOver announce the time and date on your Mac (Guide)
selecting text with Braille displays in ios 5 (Forum Topic)
Battery Monitor (Mac App Directory)
Battery Monitor: View all of the Information that you Could Ever Want About the Battery in Your MacBook Pro or Air (Podcast)
iSH Shell (iOS and iPadOS App Directory)

Site Information

  • About
  • Club AppleVis
  • FAQ
  • Contact

Unless stated otherwise, all content is copyright AppleVis. All rights reserved. © 2023 | Accessibility | Terms | Privacy