Programmatically changing OS X Menu Bar


Please briefly explain why you feel this question should be reported .

Report Cancel

I’ve been looking into a script solution to changing the OS X menu bar to Dark theme from the default. I know you can access this setting from the System Preferences > General > use dark theme checkbox, but opening System Preferences takes a little too much time for me. Also, I usually run Flux during the night, but kill it during the day, and Flux automatically force changes the menu bar back to default light style (this is why I’m changing it so often, and why I need a faster solution).

I’ve looked at man defaults for the Apple OS X system read/write commands, and I finally found the relevant setting:

$ defaults read "Apple Global Domain" AppleInterfaceStyle

returns either


if the style is set to dark, or

The domain/default pair of (kCFPreferencesAnyApplication, AppleInterfaceStyle) does not exist

if it’s not (which seems odd that the default would just be an empty attribute).

So I tried:

$ defaults write "Apple Global Domain" AppleInterfaceStyle Dark

This command ‘works’ (it returns with no errors, exit code 0, trying defaults read alleges that the “Dark” theme has been set) but doesn’t visually change the menu bar or Sherlock style to a dark theme. When I check System Preferences > General the checkbox is still unchecked: even re-launching Finder doesn’t redraw the menu bar with a dark theme.

Is there a different command I should be using instead? I’ve checked out defaults domains but there doesn’t seem to be other relevant domains I should be modifying. Is there a command to force redraw Finder I don’t know about? Or is this a lost cause?


solved 0
1 Answer 38 views 0

Answer ( 1 )

    January 12, 2017 at 10:30 am

    Please briefly explain why you feel this answer should be reported .

    Report Cancel

    You can use an AppleScript to do that:

    Here’s the command to use in Terminal (this command toggle between normal and dark mode):

    osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'

    Another solution:

    • See this page to enable the keyboard shortcut
      (Command+Option+Control+t) to switch between Dark and Light modes.
    Best answer

Leave an answer


What is the capital of Egypt ? ( Cairo )

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>