From 9ed253acb2936a5ca353e8ba867773eb7ff2797b Mon Sep 17 00:00:00 2001 From: hoamer Date: Fri, 10 Jan 2020 13:10:47 +0100 Subject: [PATCH] added option for displaying the power consumption --- bumblebee/modules/battery.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index b890137..535d38b 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -79,17 +79,24 @@ class Module(bumblebee.engine.Module): capacity = int(f.read()) except IOError: return "n/a" + capacity = capacity if capacity < 100 else 100 widget.set("capacity", capacity) - output = "{}%".format(capacity) + + # Read power conumption + if bumblebee.util.asbool(self.parameter("showpowerconsumption", False)): + r=open(widget.name + '/power_now', "r") + output = "{}% ({})".format(capacity,str(int(r.read())/1000000) + "W") + else: + output = "{}%".format(capacity) + widget.set("theme.minwidth", "100%") - if bumblebee.util.asbool(self.parameter("showremaining", True))\ and self.getCharge(widget) == "Discharging": output = "{} {}".format(output, self.remaining()) if bumblebee.util.asbool(self.parameter("showdevice", False)): - output = "{} ({})".format(output, os.path.basename(widget.name)) + output = "{} ({})".format(output, r.read()) return output