From e6e4385f9ae6dbbd4514f89d3b83aac49f681b23 Mon Sep 17 00:00:00 2001 From: elParaguayo Date: Mon, 13 Nov 2023 21:11:20 +0000 Subject: [PATCH] Fix `fraction` KeyError in `UpowerWidget` To draw the widget, the code looks up the `fraction` key in the battery's dictionary. However, if draw has been called before this information has been retrieved (as can happen at startup), a KeyError arises. This PR fixes the issue by initialising the battery with a default value of 50%. --- CHANGELOG | 1 + qtile_extras/widget/upower.py | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ceee7abd..d904b582 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +2023-11-13: [BUGFIX] Fix `fraction` KeyError in `UpowerWidget` 2023-11-13: [FEATURE] Add `invert` option to `Visualiser` to draw bars from top down 2023-11-12: [BUGFIX] (Trying to) fix increasing CPU with `Visualiser` widget 2023-11-11: [DOCS] Update installation instructions diff --git a/qtile_extras/widget/upower.py b/qtile_extras/widget/upower.py index aa3150a7..9ae89c27 100644 --- a/qtile_extras/widget/upower.py +++ b/qtile_extras/widget/upower.py @@ -229,6 +229,7 @@ async def find_batteries(self): bat["props"] = props bat["name"] = await battery_dev.get_native_path() bat["flags"] = BatteryState.NONE + bat["fraction"] = 0.5 battery_devices.append(bat)