How can I toggle the "Show date and time in menu bar" option via AppleScript. I'm using OSX 10.10.4.

I am looking for a working example in AppleScript.

  • toggle between date and time showing ?
    – Ruskes
    Jul 14 '15 at 2:00
  • The option to hide or show the date and time in the menu bar.
    – Zero21xxx
    Jul 14 '15 at 2:05
  • There are three ways to do it. Use GUI scripting to access the checkbox inside System Preferences. Or use defaults write to change com.apple.systemuiserver and then killall systemuiserver. A commercial solution is Bartender. Jul 14 '15 at 9:52

Here is some code that's working on my elderly MacMini'09. "delay" may have to be adjusted ...

tell application "System Preferences"
    tell application "Finder" to set position of window 1 of process ¬
        "System Preferences" to {1200, 1000}
    set current pane to pane id "com.apple.preference.datetime"
end tell
tell application "System Events" to tell process "System Preferences"
    delay 0.5
    click checkbox "Datum und Uhrzeit in der Menüleiste anzeigen" of ¬
        tab group of window 1
end tell
quit application "System Preferences"
  • I left German strings in the script to avoid home-brew English "translations" > DIY !
  • Directly upon System-Preferences' launching, its app window is "hidden" to some corner
  • There's a delay as otherwise things would not work before the final shutdown ...

... Oh, btw, I would recommend to install a keyboard shortcut via Automator/services (all apps)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .