fix: try catch excepton in get_windows_dark_mode and global cache the check (#1587)

* fix: try catch excepton on get_windows_dark_mode and global cache that check

* add commitor email to CONTRIBUTORS

* remove is_windows_dark_mode cache

* avoid logging the missing key (dae)

The check happens frequently, so this will fill up the user's console if we print it each time.
This commit is contained in:
qxo 2022-01-16 12:07:28 +08:00 committed by GitHub
parent 77b1546583
commit 492f0a5e32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -89,6 +89,7 @@ lolilolicon <lolilolicon@gmail.com>
Gesa Stupperich <gesa.stupperich@gmail.com> Gesa Stupperich <gesa.stupperich@gmail.com>
git9527 <github.com/git9527> git9527 <github.com/git9527>
Vova Selin <vselin12@gmail.com> Vova Selin <vselin12@gmail.com>
qxo <49526356@qq.com>
******************** ********************

View file

@ -327,7 +327,11 @@ def get_windows_dark_mode() -> bool:
HKEY_CURRENT_USER, HKEY_CURRENT_USER,
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
) )
return not QueryValueEx(key, "AppsUseLightTheme")[0] try:
return not QueryValueEx(key, "AppsUseLightTheme")[0]
except Exception as err:
# key reportedly missing or set to wrong type on some systems
return False
def set_macos_dark_mode(enabled: bool) -> bool: def set_macos_dark_mode(enabled: bool) -> bool: