I have a program that needs to turn on and off the system clock in the menu bar. This will do that:
defaults write com.apple.MenuBarClock ClockEnabled -bool false
(with false
->true
to turn it back on).
Except it doesn't actually take effect until I manually open up Date & Time settings (just opening the settings causes the menu bar to refresh and the clock to appear or disappear per the "defaults write" command previously issued).
The question:
Is there a command to refresh the display of the menu bar? Or to programmatically open the Date & Time system preferences?
PS: Thanks to the first answer for pointing out "killall SystemUIServer" but in addition to bizarre problem I'm having with that, it seems to be too slow. The whole menubar refreshes and it takes like a full second. I really want to just toggle the clock on and off, like what happens when you manually click "Show date and time in menu bar" in the Date and Time preferences.