Created
August 8, 2020 02:53
-
-
Save t-lark/2eca6e625f740544975122d3615079d6 to your computer and use it in GitHub Desktop.
detect dark, light, or auto mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from SystemConfiguration import SCDynamicStoreCopyConsoleUser | |
>>> from CoreFoundation import CFPreferencesCopyAppValue | |
>>> from Foundation import NSHomeDirectoryForUser | |
>>> | |
>>> user, uid, gid = SCDynamicStoreCopyConsoleUser(None, None, None) | |
>>> home = NSHomeDirectoryForUser(user) | |
>>> userfile = home + '/Library/Preferences/.GlobalPreferences.plist' | |
>>> keys = ['AppleInterfaceStyle', 'AppleInterfaceStyleSwitchesAutomatically'] | |
# just loop and see what we get | |
>>> for k in keys: | |
... print(CFPreferencesCopyAppValue(k, userfile)) | |
... | |
Dark | |
None | |
>>> | |
# test for None values | |
>>> for k in keys: | |
... result = CFPreferencesCopyAppValue(k, userfile) | |
... if result is not None: | |
... print(result) | |
... | |
Dark | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment