macos-defaults
macos-defaults copied to clipboard
Enable dark mode
defaults write -globalDomain AppleInterfaceStyle Dark
after: sudo killall -HUP WindowServer
Hi @yannbertrand, I would like to work on it!
Nice. Let me know if the command is not working, I'm not sure it is
Confirmed working on Big Sur.
Note that sudo killall -HUP WindowServer logs you out.
Please note the killall commands force closes all opened sessions. I just did it on my computer, I couldn't reopen Firefox nor VSCode because "a session is still opened" 😅
Turns out there is no easy solution to refresh WindowServer programmatically.
Usual solution seems not to use a default but AppleScript like this:
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to 1'
See https://www.reddit.com/r/MacOS/comments/92o7e3/control_the_macos_dark_mode_from_the_terminal/