albertosottile / darkdetect

Detect OS Dark Mode from Python
Other
171 stars 18 forks source link

Detect dark mode on Windows 10 #2

Closed midrare closed 3 years ago

midrare commented 4 years ago

Apparently Windows 10 has dark mode too. I wrote this if you would consider extending darkdetect functionality to Windows.

import platform

if platform.system() == 'Windows':
    import winreg

def is_windows_using_dark_theme():
    value = 1 # default to light theme

    try:
        with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize') as key:
            value, value_type = winreg.QueryValueEx(key, 'AppsUseLightTheme')
    except OSError as e:
        pass

    return value > 0
marticliment commented 3 years ago

I've tried this and it works perfectly.

albertosottile commented 3 years ago

Closed in #4. To be released soon in 0.2.