Don't react to psuedo Dark Mode on pre-Mojave unless AllowDarkModeOnUnsupportedOSes pref is set

This commit is contained in:
Greg Neagle
2018-08-30 21:28:56 -07:00
parent 5c05072f85
commit bcc25d77bf
2 changed files with 8 additions and 5 deletions

View File

@@ -75,13 +75,13 @@ class MSCAppDelegate(NSObject):
# without the Retina assets to avoid an appearance issue when the
# icon has a badge in the Dock (and App Switcher)
# Darwin major version 10 is Snow Leopard (10.6)
if os.uname()[2].split('.')[0] == '10':
if int(os.uname()[2].split('.')[0]) == 10:
myImage = NSImage.imageNamed_("Managed Software Center 10_6")
NSApp.setApplicationIconImage_(myImage)
# if we are running under Mountain Lion or later set ourselves as a delegate
# for NSUserNotificationCenter notifications
if os.uname()[2].split('.')[0] > '11':
if int(os.uname()[2].split('.')[0]) > 11:
NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)
# have the statuscontroller register for its own notifications

View File

@@ -24,9 +24,12 @@ from Foundation import NSString, NSLocalizedString, NSUTF8StringEncoding
def interfaceStyle():
'''Returns "dark" if using Dark Mode, otherwise "light"'''
interfaceType = NSUserDefaults.standardUserDefaults().stringForKey_("AppleInterfaceStyle")
if interfaceType == "Dark":
return "dark"
# running under Mojave or later or undocumented pref is set
if (int(os.uname()[2].split('.')[0]) >= 18 or
NSUserDefaults.standardUserDefaults().boolForKey_("AllowDarkModeOnUnsupportedOSes")):
interfaceType = NSUserDefaults.standardUserDefaults().stringForKey_("AppleInterfaceStyle")
if interfaceType == "Dark":
return "dark"
return "light"
def quote(a_string):