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!
我为这个目的制作了一个命令行应用程序: dark-mode
。
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
I'm not entirely certain, but you might need to restart some services to refresh it too:
sudo killall Dock;killall SystemUIServer;killall Finder;killall cfprefsd
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.