[modules/battery_all] Fix remaining time calculation

Thanks to @stoeps13 for pointing out a bug in the calculation of the
remaining time for multiple batteries.

see #379
This commit is contained in:
Tobias Witek 2019-04-23 06:05:36 +02:00
parent 011b3b631b
commit e0a7ca5b87

View file

@ -6,6 +6,7 @@ Parameters:
* battery.device : Comma-separated list of battery devices to read information from (defaults to auto for auto-detection) * battery.device : Comma-separated list of battery devices to read information from (defaults to auto for auto-detection)
* battery.warning : Warning threshold in % of remaining charge (defaults to 20) * battery.warning : Warning threshold in % of remaining charge (defaults to 20)
* battery.critical : Critical threshold in % of remaining charge (defaults to 10) * battery.critical : Critical threshold in % of remaining charge (defaults to 10)
* batter.showremaining : If set to true (default) shows the remaining time until the batteries are completely discharged
""" """
import os import os
@ -84,7 +85,7 @@ class Module(bumblebee.engine.Module):
widget.set("capacity", 100) widget.set("capacity", 100)
return "ac" return "ac"
capacity = int( self.energy_now / self.energy_full * 100) capacity = int( float(self.energy_now) / float(self.energy_full) * 100.0)
capacity = capacity if capacity < 100 else 100 capacity = capacity if capacity < 100 else 100
widget.set("capacity", capacity) widget.set("capacity", capacity)
output = "{}%".format(capacity) output = "{}%".format(capacity)