Q: How do you check battery level using a speakable command in OSX?
I am trying to assist a student of ours at my school who is using a MacBook Air as part of our one-to-one initiative. In trying to help her get all of her Accessibility features working for her, we ran into a stumper: How can you get a MacBook Air to tell a user (who is completely blind) what the status of his/her battery is? VoiceOver does not pick it up from the Menu Bar. I don't see a Speakable Command for it. We cannot find the status or another menu that has speakable text to tell the user about the percentage or hours remaining... this is very frustrating for a student who is used to simply asking Siri to tell her the status of her battery!
In trying to find a solution, I thought of creating our own speakable command (through Automator and then creating the command), but, again, I just can't find the clicks to get us a percentage or hours that can be read. I hope Apple reps take note that my previous praise of OSX as a more accessible platform has a very serious hole in it when the user cannot tell when his/her device is about to die.
Sidebar:
When on earth will Apple embed Siri into OSX instead of relying on its library of speakable commands (which falls short in this case!)?
MacBook Air, Mac OS X (10.7.4)
Posted on Dec 4, 2013 8:46 AM
Here is a fully functional example of a Speakable Items battery level checker. It determines if you are on a desktop, or laptop. In the latter case, it speaks to you differently if you have a power cord attached, or are strictly on battery power.
You will need to enable Speakable Items in System Preferences > Accessibility (Mavericks), or in the Speech panel (Lion). Haven't tested this on Mountain Lion. In either case, a new Speech folder will be created in your local Library folder.
Copy and paste the following code into the AppleScript Editor, initially save it as text (battery-level.applescript) for safe-keeping, and then with the option key pressed, choose File > Save As... and save it as a script (with no file extension) into your login directory/Library/Speech/Speakable Items folder.
(*
Speakable items addition that recites current battery info.
Open in AppleScript Editor and Save As… script without extension
into login directory/Library/Speech/Speakable Items folder.
Name suggestion: Battery level.
Works exactly as coded. Though intended for visually challenged, it will
output a text banner containing the speech content if audio is off.
Tested on OS X 10.7.5 and 10.9
VikingOSX, December 2013, Apple Support Community
*)
set theList to {}
set thePct to ""
set theHr to ""
set theMin to ""
set status to ""
set expression to ""
set theList to paragraphs of text of (do shell script "pmset -g batt")
set itemCnt to count of items in theList
if (itemCnt = 1) then
say "Desktop Device not equipped with battery."
return
end if
set thePct to word 3 of theList's item 2
set theHr to word 5 of theList's item 2
set theMin to word 6 of theList's item 2
--trim leading zero
if (theMin begins with "0") then set theMin to text 2 thru -1 of theMin
if theList's item 1 contains "AC Power" and ¬
theList's item 2 contains "; charging" then
set status to "power cord"
if (theHr is "0") then
set expression to "Currently on " & status & ¬
" with the battery at " & thePct & ¬
" percent, and " & theMin & " minutes to full charge."
else if (theHr is "1") then
set expression to "Currently on " & status & ¬
" with the battery at " & thePct & ¬
"percent , and " & theHr & ¬
" hour, and " & theMin & " minutes to full charge."
else
set expression to "Currently on " & status & ¬
" with the battery at " & thePct & ¬
"percent , and " & theHr & ¬
" hours, and " & theMin & " minutes to full charge."
end if
else
set status to "battery power"
if (theHr is "0") then
set expression to "Currently on " & status & ¬
" with " & thePct & ¬
" percent charge, and " & theMin ¬
& " minutes remaining."
else if (theHr is "1") then
set expression to "Currently on " & status & ¬
" with " & thePct & ¬
"percent charge, and " & theHr & ¬
" hour, and " & theMin & " minutes remaining."
else
set expression to "Currently on " & status & ¬
" with " & thePct & ¬
"percent charge, and " & theHr & ¬
" hours, and " & theMin & " minutes remaining."
end if
end if
say expression
Posted on Dec 6, 2013 6:21 PM