macos-defaults icon indicating copy to clipboard operation
macos-defaults copied to clipboard

Enable dark mode

Open yannbertrand opened this issue 5 years ago • 3 comments

defaults write -globalDomain AppleInterfaceStyle Dark after: sudo killall -HUP WindowServer

yannbertrand avatar Sep 05 '20 20:09 yannbertrand

Hi @yannbertrand, I would like to work on it!

valentinperignon avatar Jan 02 '21 13:01 valentinperignon

Nice. Let me know if the command is not working, I'm not sure it is

yannbertrand avatar Jan 02 '21 20:01 yannbertrand

Confirmed working on Big Sur. Note that sudo killall -HUP WindowServer logs you out.

jottr avatar Jun 01 '21 20:06 jottr

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" 😅

yannbertrand avatar Aug 19 '22 09:08 yannbertrand

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/

yannbertrand avatar Aug 19 '22 14:08 yannbertrand