En quelques lignes de Python, il est simple de savoir si le dark mode est activé par l'utilisateur.
# python -m pip install pyobjc-framework-Cocoa
from Foundation import NSUserDefaults
def current_them() -> str:
"""Get the current OS them."""
try:
theme = NSUserDefaults.standardUserDefaults().stringForKey_(
"AppleInterfaceStyle"
)
return theme.lower()
except Exception:
return ""
def dark_mode_in_use() -> bool:
"""Does the user has the Dark mode set?"""
return current_them() == "dark"