added option for displaying the power consumption

This commit is contained in:
hoamer 2020-01-10 13:10:47 +01:00
parent f48c468975
commit 9ed253acb2

View file

@ -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