Skip to content

Commit

Permalink
Adjust detection of interfaceMode ('dark/light') to handle auto-switc…
Browse files Browse the repository at this point in the history
…hing intro'd in 10.15
  • Loading branch information
gregneagle committed Aug 26, 2021
1 parent 0cd2f68 commit e1ad739
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -17,13 +17,19 @@ extension Array {
}
}


func interfaceTheme() -> String {
// Returns "dark" if using Dark Mode, otherwise "light"
if #available(OSX 10.10, *) {
if #available(OSX 10.15, *) {
let appearanceDescription = NSApplication.shared.effectiveAppearance.debugDescription.lowercased()
if appearanceDescription.contains("dark") {
return "dark"
}
} else if #available(OSX 10.10, *) {
let os_vers = OperatingSystemVersion(majorVersion: 10, minorVersion: 14, patchVersion: 0)
if ProcessInfo().isOperatingSystemAtLeast(os_vers) || UserDefaults.standard.bool(forKey: "AllowDarkModeOnUnsupportedOSes") {
if let interfaceType = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") {
if interfaceType == "Dark" {
if let appleInterfaceStyle = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") {
if appleInterfaceStyle.lowercased().contains("dark") {
return "dark"
}
}
Expand All @@ -32,6 +38,7 @@ func interfaceTheme() -> String {
return "light"
}


func getRawTemplate(_ template_name: String) -> String {
// return a raw html template.
let customTemplatesPath = NSString.path(withComponents: [html_dir(), "custom/templates"])
Expand Down

0 comments on commit e1ad739

Please sign in to comment.