How do I enable "Announce the time" programmatically? The "Date &amp; Time" System Preferences pane has an option to "Announce the time". I'd like to be able to turn on this preference option by invoking a shell script. Is this possible?

(It's fine if this involves invoking a separate script written in Applescript).
That preference seems to be stored in com.apple.speech.synthesis.general.prefs

Try this:

defaults write com.apple.speech.synthesis.general.prefs TimeAnnouncementPrefs -dict-add TimeAnnouncementsEnabled 1


or 0 at the end to turn it off. See man defaults for more info.

Edit: Another thing that the shell script should do: if you haven't enabled this preference or another speech synthesis behavior since startup, you'll also need to launch the Speech Synthesis Server daemon:

open /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesisServer.app


otherwise, the option will show up as checked in System Preferences, but nothing will actually read the option when it is time to speak the time.