Zend certified PHP/Magento developer

Force reset system preferences cache on macOS Big Sur

I’m trying to enable/disable time announcement feature that’s present in Dock & Menu Bar > Clock > Announce the time with a shell script.

system preference window

When I read the plist file, I can see that it’s set to 0.

> defaults read com.apple.speech.synthesis.general.prefs
{
    TimeAnnouncementPrefs =     {
        TimeAnnouncementsEnabled = 0;
        TimeAnnouncementsIntervalIdentifier = EveryQuarterHourInterval;
        TimeAnnouncementsPhraseIdentifier = ShortTime;
        TimeAnnouncementsVoiceSettings =         {
            CustomVolume = "0.5";
            VoiceIdentifier = "com.apple.speech.synthesis.voice.samantha.compact";
        };
    };
}

Then I can enable it with:

> /usr/libexec/PlistBuddy -c "set :TimeAnnouncementPrefs:TimeAnnouncementsEnabled 1" ~/Library/Preferences/com.apple.speech.synthesis.general.prefs.plist
> defaults read com.apple.speech.synthesis.general.prefs

which turns on the feature without a problem.

When I set it to 0 to disable it, it changes the plist file, and the system preferences app shows it disabled (grayed out). But it continues announcing the time. I have to manually go to settings and turn the feature on & off to get it to apply.

These are the commands I used:

Approach 1: using PlistBuddy

> /usr/libexec/PlistBuddy -c "set :TimeAnnouncementPrefs:TimeAnnouncementsEnabled 0" ~/Library/Preferences/com.apple.speech.synthesis.general.prefs.plist
> defaults read com.apple.speech.synthesis.general.prefs

Approach 2: using defaults

I also tried writing the whole dictionary at once using just defaults

defaults write com.apple.speech.synthesis.general.prefs '{TimeAnnouncementPrefs={TimeAnnouncementsEnabled=1;TimeAnnouncementsIntervalIdentifier=EveryQuarterHourInterval;TimeAnnouncementsVoiceSettings={CustomVolume="0.5";VoiceIdentifier="com.apple.speech.synthesis.voice.samantha.compact";};};}'

Approach 3: replacing the file

I also tried replacing the whole file with the copies I made of both states (enabled.plist and disabled.plist) and calling defaults read com.apple.speech.synthesis.general.prefs

All these approaches change the setting. When I quit and reopen preferences app, I can see that it’s disabled. However it doesn’t take effect.


I tried running all of these to force it to reload but it didn’t help.

> defaults read com.apple.speech.synthesis.general.prefs
> killall cfprefsd
> defaults read ~/Library/Preferences/com.apple.speech.synthesis.general.prefs.plist

How can I get System Preferences to load the settings from plist files and apply them?

I’m running macOS Big Sur 11.4 (20F71)