summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStefan Huber <shuber@sthu.org>2022-12-30 13:04:06 +0100
committerStefan Huber <shuber@sthu.org>2022-12-30 13:51:04 +0100
commited355dbf46e370c7a9207001a8007ff9bc929b73 (patch)
treef1c9c9d8cfaac38ae88f1a8b0d881388c425d706 /scripts
parent0aba2f2e13cc4a20a0b8ab87535cd3ebc61ea66a (diff)
battery-widget: Sanitize total charge computation
The code to parse the output of `acpi -i` is fragile as it does not guarantee that the same number of battery status and capacities are read. This causes a wrong computation of the total charge level when batteries of status "Unknown" are reported. For instance, this is what `acpi -i` reports with a Wacom Intuos S attached to a Thinkpad T460s: $ acpi -i Battery 0: Unknown, 0%, rate information unavailable Battery 1: Not charging, 98% Battery 1: design capacity 1857 mAh, last full capacity 1513 mAh = 81% Battery 2: Not charging, 98% Battery 2: design capacity 2051 mAh, last full capacity 1711 mAh = 83% Fix the code by guaranteeing that for each battery status parsed there is also a capacity, which is zero if no capacity can be parsed. This effectively causes the exclusion of such batteries when computing the total charge level.
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions