Search code examples
macosshellapplescriptsettingsosx-yosemite

Enabling Yosemite's Dark mode through Terminal or Applescript OSX 10.1


Is there any way to turn on Yosemite's Dark Mode through Shell Script (Terminal) or Applescript? I have tried:

sudo defaults write /Library/Preferences/.GlobalPreferences AppleInterfaceTheme Dark

but it does not work.

Please help!


Solution

  • I figured it out.

    I did it in Applescript like this:

    do shell script ("sudo defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true") with administrator privileges
    tell application "Finder" to activate
    delay 0.2
    tell application "System Events"
    key code "17" using {option down, control down, command down}     #Option+Control+Command+T
    end tell