3

general

I found the way to set dark mode:

defaults write -g NSRequiresAquaSystemAppearance -bool true

But have no idea set it to Auto with defaults write.

It could also be great to explain how you discovered this.

Thank you!

  • What does Auto mean when used with dark mode- light mode? – jmh May 21 at 2:05
  • @jmh it means set dark mode on sunset and set light mode on sunrise. – Will Chang May 21 at 8:42
  • Ok, thanks! i should have guessed that. Sorry! – jmh May 21 at 13:11
  • You basically want to revert setting your computer to permanent dark mode, right? Googled your script and found a related question, is the first comment on this answer what you're looking for? stackoverflow.com/a/52563021/4722345 possibly defaults delete -g NSRequires... – JBallin May 21 at 23:59
  • @JBallin Thank you and I want to set the light/dark mode to auto, it depends on sunrise/sunset. MacOS Catalina has provided this feature(the image in the question), I want to set it from terminal with a script. – Will Chang May 22 at 0:38
2

The answer is in step 7 and step 9.

  1. Setup git in the ~/Library/Preferences/ folder to determine the incoming changes.

    cd ~/Library/Preferences/
    git init
    git add .
    git commit -m "init commit"
    
  2. Open System Preferences -> General, change Appearance from Light to Auto. I found only .GlobalPreferences.plist has been changed.
  3. Open .GlobalPreferences.plist in VSCode with Binary Plist plugin to view plist file as xml syntax.
  4. Copy the .GlobalPreferences.plist file content in VSCode and paste to Diffchecker Original Text.
  5. Change Appearance from Auto to Light.
  6. Copy the .GlobalPreferences.plist file content in VSCode and paste to Diffchecker Changed Text. I found the diff content is:

    <key>AppleInterfaceStyleSwitchesAutomatically</key>
    <true/>
    
  7. Run the defaults write command to set the Appearance to Auto

    defaults write -g AppleInterfaceStyleSwitchesAutomatically -bool true
    
  8. Remove the .git in ~/Library/Preferences/
  9. Log out and log in the computer.
  10. Open System Preferences -> General. You'll see the Appearance is set to Auto.
| improve this answer | |
  • git diff can be used for untracked files too. So you just need to make copies & use git diff <path to file 1> <path to file 2> – ankii May 22 at 9:56
  • @ankii Thank you! I didn't know that and I tried git diff * but it didn't show the expecting content, maybe because of the plist is binary file? I also found that VSCode didn't highlight the changes. Please correct me if I was wrong. ;) – Will Chang May 23 at 0:37
  • 1
    right, it's due to the files being binary. But ordinarily, text files can be compared like that. So I used Xcode to export text/ XML file. Then I was able to compare them easily. If you're feeling courageous, use hexdump to compare them ;) superuser.com/questions/125376/… rawsyntax.com/blog/comparing-plist-files-on-osx – ankii May 23 at 8:41
  • Awesome! Thanks for opening my eyes! – Will Chang May 23 at 13:31

You must log in to answer this question.

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