AppKit API to control system dark mode

Originator:sindresorhus
Number:rdar://42137875 Date Originated:13-Jul-2018 04:32 AM
Status:Open Resolved:
Product:macOS + SDK Product Version:10.13.5
Classification:Feature (New) Reproducible:Always
 
Summary:
It's useful for both users and app developers to be able to control dark mode. Having an API for this would enable developers to make apps that, for example, toggles dark mode at a specific time or place.

Currently, it's possible to control dark mode with AppleScript*, but that does not work when sandboxed in the App Store... We need a native sandbox-compatible API for this!


* `tell application "System Events" to tell appearance preferences to not dark mode`

Steps to Reproduce:
 

Expected Results:
 

Actual Results:
 

Version:
10.13.5

Notes:
I imagine the API could be something like this:

```swift
DarkMode.isEnabled = true

print(DarkMode.isEnabled)

DarkMode.onChange {
	print("Is Dark Mode", DarkMode.isEnabled)
}
```

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!