Skip to content

Commit 8f0375e

Browse files
committed
Fix #33 by checking if display is fully detected
1 parent 063c3ec commit 8f0375e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

screen_brightness_control/windows.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,19 @@ def get_display_info() -> List[dict]:
9090
model, serial, manufacturer, man_id, edid = None, None, None, None, None
9191
instance_name = monitor.InstanceName.replace(
9292
'_0', '', 1).split('\\')[2]
93-
pydevice = monitor_uids[instance_name]
93+
try:
94+
pydevice = monitor_uids[instance_name]
95+
except KeyError:
96+
# if laptop display WAS connected but was later put to sleep (#33)
97+
if instance_name in laptop_displays:
98+
laptop += 1
99+
else:
100+
desktop += 1
101+
_logger.warning(
102+
f'display {instance_name!r} is detected but not present in monitor_uids.'
103+
' Maybe it is asleep?'
104+
)
105+
continue
94106

95107
# get the EDID
96108
try:

0 commit comments

Comments
 (0)