Skip to content

Commit 10a0c96

Browse files
Windows: catch FileNotFoundError for headless setups (improved)
1 parent 044eefc commit 10a0c96

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

darkdetect/_windows_detect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def theme():
77
# In HKEY_CURRENT_USER, get the Personalisation Key.
88
try:
99
key = getKey(hkey, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize")
10+
# In the Personalisation Key, get the AppsUseLightTheme subkey. This returns a tuple.
11+
# The first item in the tuple is the result we want (0 or 1 indicating Dark Mode or Light Mode); the other value is the type of subkey e.g. DWORD, QWORD, String, etc.
12+
subkey = getSubkeyValue(key, "AppsUseLightTheme")[0]
1013
except FileNotFoundError:
1114
# some headless Windows instances (e.g. GitHub Actions or Docker images) do not have this key
1215
return None
13-
# In the Personalisation Key, get the AppsUseLightTheme subkey. This returns a tuple.
14-
# The first item in the tuple is the result we want (0 or 1 indicating Dark Mode or Light Mode); the other value is the type of subkey e.g. DWORD, QWORD, String, etc.
15-
subkey = getSubkeyValue(key, "AppsUseLightTheme")[0]
1616
return valueMeaning[subkey]
1717

1818
def isDark():

0 commit comments

Comments
 (0)