How programmatically get value of Increase contrast setting on macOS Hight Sierra? Also interesting to know how to observe that value change.
Full path to system preference is System Preferences -> Accessibility -> Display -> Increase contrast.
On macOS Mojave it can be achieved via effectiveAppearance.bestMatch
API call like below.
open override func layout() {
super.layout()
if #available(OSX 10.14, *) {
if let value = effectiveAppearance.bestMatch(from: [.aqua, .darkAqua, .accessibilityHighContrastAqua, .accessibilityHighContrastDarkAqua]) {
switch value {
case .aqua:
setupAppearance(.light)
case .darkAqua:
setupAppearance(.dark)
case .accessibilityHighContrastAqua:
setupAppearance(.highContrastLight)
case .accessibilityHighContrastDarkAqua:
setupAppearance(.highContrastDark)
default:
break
}
}
}
}
Starting on macOS 10.10 you can use this API of NSWorkspace.