albertosottile / darkdetect

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

[RFC] macOS code choices #3

Closed jrappen closed 4 years ago

jrappen commented 4 years ago

Hi, first of all thanks for sharing the code.


I'm curious, was there a specific reason why you didn't choose this simpler way of detecting dark mode?

# querying for dark mode

try:
    get_status = 'defaults read -g AppleInterfaceStyle'
    import subprocess
    status = subprocess.check_output(
        get_status.split(),
        stderr = subprocess.STDOUT
    ).decode()
    status = status.replace('\n', '')
except subprocess.CalledProcessError as e:
    return False
return True if status.lower() == 'dark' else False