Merge pull request #150 from fredj/battery_remaining

[module/battery] Simplify remaining time computation
This commit is contained in:
tobi-wan-kenobi 2017-07-30 10:21:06 +02:00 committed by GitHub
commit be4f4cb68f

View file

@ -53,14 +53,11 @@ class Module(bumblebee.engine.Module):
def remaining(self): def remaining(self):
estimate = 0.0 estimate = 0.0
try: try:
power_type = power.PowerManagement().get_providing_power_source_type()
# do not show remaining if on AC
if power.PowerManagement().get_providing_power_source_type() == power.POWER_TYPE_AC:
return None
estimate = power.PowerManagement().get_time_remaining_estimate() estimate = power.PowerManagement().get_time_remaining_estimate()
if estimate == -1.0: # do not show remaining if on AC
if estimate == power.common.TIME_REMAINING_UNLIMITED:
return None
if estimate == power.common.TIME_REMAINING_UNKNOWN:
return "n/a" return "n/a"
except Exception: except Exception:
return "n/a" return "n/a"