Skip to content

Commit

Permalink
Fix fraction KeyError in UpowerWidget
Browse files Browse the repository at this point in the history
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%.
  • Loading branch information
elParaguayo committed Nov 13, 2023
1 parent e2d74f1 commit e6e4385
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions qtile_extras/widget/upower.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e6e4385

Please sign in to comment.