rythmium

Q: How can I automate the "use dark menu bar and dock" preference in Yosemite?

I love the dark menu bar and dock feature in OSX Yosemite! However, I think it would be perfect if I could change it without having to open System Preferences every time. I have absolutely no experience whatsoever with AppleScript, but I'm trying to figure out how to write an AppleScript that will set the dark setting to on or off. I found this example on macosxautomation.com:

 

tell application "System Events"

tell appearance preferences

get properties

--> returns: {scroll arrow placement:together, font smoothing limit:4, recent applications limit:10, scroll bar action:jump to next page, double click minimizes:true, recent servers limit:10, appearance:blue, recent documents limit:10, highlight color:{46516, 54741, 65535}, class:appearance preferences object, smooth scrolling:false, font smoothing style:automatic}

set properties to {scroll arrow placement:together at top and bottom, font smoothing limit:4, recent applications limit:10, scroll bar action:jump to here, double click minimizes:true, recent servers limit:20, appearance:blue, recent documents limit:20, highlight color:{0, 0, 32000}, smooth scrolling:true, font smoothing style:light}

end tell

end tell


It looks promising, but those properties are obviously for an older version of OSX. Since I'm so new to this, I don't know how to define a new property to modify. This is what I tried (which didn't work):


tell application "System Events"

tell appearance preferences

get properties

set properties to {Use dark menu bar and Dock:true}

end tell

end tell


This also didn't work (all I did was add quotation marks in line 4):


tell application "System Events"

tell appearance preferences

get properties

set properties to {"Use dark menu bar and Dock":true}

end tell

end tell


Any ideas as to how to do this? Once I have this AppleScript written, I can easily throw it into Automator to make it change with the time of day. I can't wait! Any help is greatly appreciated. Have a wonderful day!

MacBook Air, OS X Yosemite (10.10.5), 256GB, 8GB LPDDR3 1600, 1.6GHz i5

Posted on Aug 29, 2015 3:53 PM

Close

Q: How can I automate the "use dark menu bar and dock" preference in Yosemite?

  • All replies
  • Helpful answers

  • by Barney-15E,Solvedanswer

    Barney-15E Barney-15E Aug 29, 2015 4:08 PM in response to rythmium
    Level 9 (50,593 points)
    Mac OS X
    Aug 29, 2015 4:08 PM in response to rythmium

    The way to find out what is scriptable is to open the Dictionary for that app in Script editor. For the Appearance Suite, you'd see:

    Screen Shot 2015-08-29 at 6.05.18 PM.png

    Here is the script to set the dark mode on.

    tell application "System Events"

      tell appearance preferences

        set dark mode to true

      end tell

    end tell

  • by rythmium,

    rythmium rythmium Aug 29, 2015 8:54 PM in response to Barney-15E
    Level 1 (0 points)
    Aug 29, 2015 8:54 PM in response to Barney-15E

    You, sir, are a godsend. I put your script in an Automator application and scheduled it to run every evening at 7pm. I also changed "true" to "false" and scheduled that version for 6am every morning. Now I have a computer that adapts to its environment a lot better. Thank you so much! And, as a plus, I learned about the AppleScript dictionary!

  • by Vikrorious,

    Vikrorious Vikrorious Sep 26, 2016 5:43 PM in response to rythmium
    Level 1 (18 points)
    Notebooks
    Sep 26, 2016 5:43 PM in response to rythmium

    Hi and Good Evening,

    You talked about how you put a script into an Automator application and scheduled it to run every evening at 7 pm. How did you do this??? How do you schedule automator by time of day?