Merge pull request #523 from hoamer/display_power_consumption

added option for displaying the power consumption
This commit is contained in:
tobi-wan-kenobi 2020-01-18 13:48:48 +01:00 committed by GitHub
commit 91ca082627
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,11 +79,18 @@ class Module(bumblebee.engine.Module):
capacity = int(f.read()) capacity = int(f.read())
except IOError: except IOError:
return "n/a" return "n/a"
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)
widget.set("theme.minwidth", "100%")
# 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))\ if bumblebee.util.asbool(self.parameter("showremaining", True))\
and self.getCharge(widget) == "Discharging": and self.getCharge(widget) == "Discharging":
output = "{} {}".format(output, self.remaining()) output = "{} {}".format(output, self.remaining())