From e0a7ca5b87d677a21a3221e9febac85015c15a46 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Tue, 23 Apr 2019 06:05:36 +0200 Subject: [PATCH] [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 --- bumblebee/modules/battery_all.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/battery_all.py b/bumblebee/modules/battery_all.py index 633e0d6..95a38a0 100644 --- a/bumblebee/modules/battery_all.py +++ b/bumblebee/modules/battery_all.py @@ -3,9 +3,10 @@ """Displays battery status, remaining percentage and charging information. Parameters: - * 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.critical : Critical threshold in % of remaining charge (defaults to 10) + * 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.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 @@ -84,7 +85,7 @@ class Module(bumblebee.engine.Module): widget.set("capacity", 100) 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 widget.set("capacity", capacity) output = "{}%".format(capacity)