Hi everyone,
I recently had to do a reinstall of Mac OS, and lost some scripts I had. I don't really know how to successfully modify existing scripts or how to create new ones.
I already have the script to make Voiceover say the time, and that works okay, but would like to modify it so it doesn't also read the date, as I don't need that info. I want just the time. If anyone has a modified script that would do the trick, please let me know. Also, I used to have a script that would read battery status. If anyone has that and could pass it along, it would be much appreciated.
By Justin Harris, 11 August, 2021
Forum
macOS and Mac Apps
Comments
Time script
The following script will speak the time in 12 hour format using the Ava voice. Simply swap out “Ava” for your own preferred voice.
set currentDate to current date
set amPM to "AM"
set currentHour to (currentDate's hours)
set currentMinutes to currentDate's minutes
if (currentHour ≥ 12 and currentHour < 24) then
set amPM to "PM"
else
set amPM to "AM"
end if
-- make minutes below 10 sound nice
if currentMinutes < 10 then
set currentMinutes to ("0" & currentMinutes) as text
end if
-- ensure 0:nn gets set to 12:nn AM
if currentHour is equal to 0 then
set currentHour to 12
end if
-- readjust for 12 hour time
if (currentHour > 12) then
set currentHour to (currentHour - 12)
end if
set currentTime to "The current time is " & (currentHour as text) & ":" & ((currentMinutes) as text)
say currentTime using "Ava"
delay 2
Battery script
The following script will speak the remaining battery percentage using the Ava voice. Simply swap out “Ava” for your own preferred voice.
set maxCapacity to do shell script "ioreg -w0 -l | grep \"\\\"MaxCapacity\\\" = \""
set maxLevel to the last word of maxCapacity
set curCapacity to do shell script "ioreg -w0 -l | grep \"\\\"CurrentCapacity\\\" = \""
set curLevel to the last word of curCapacity
set battPct to round (100 * curLevel / maxLevel)
set output to "Battery " & battPct & "%"
say "Battery " & battPct & "%" using "Ava"
Question
Hi, thank you for providing these scripts. I have a question. I copied these scripts exactly as written in the script editor but they don't appear when I try to assign a commander to run them. I was wondering if you'd be willing to briefly clarify what I need to paste into the script source and script description fields? Thanks in advance!
Simple Time Script
Open AppleScript and paste the following into the source area:
tell application "VoiceOver" to say (do shell script "date +\"%l:%M %p\"") using "Karen" speaking rate 270 volume 0.4
Replace 'Karen' with whatever voice you prefer. Save the script wherever and add it to Keyboard Commander within the VoiceOver Utility. Press your assigned shortcut key and voila, this will tell you ONLY the time in 12 hour format.
If you prefer a 24 hour format, reply below. :)
Thank you for the script!
Brilliant! Thanks so much! This is exactly what I wanted. I have successfully added the script!
What?
What? Really? BRB while I add this to my very long list of ppersonal projects to tackle... (unless you're feeling generous enough to paste it here?) 🥺
Of course, none of this is…
Of course, none of this is necessary any longer in Ventura: there are built-in actions for time, date and battery. Joy!