From 9be1dbc1e0abf2eed9575b3af048fa0e0d6495f6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Sun, 30 Jul 2017 08:57:56 +0200 Subject: [PATCH] [module/battery] Simplify remaining time computation The `power` module already return a special value on AC: `power.common.TIME_REMAINING_UNLIMITED` --- bumblebee/modules/battery.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bumblebee/modules/battery.py b/bumblebee/modules/battery.py index 2237b2d..f5e565e 100644 --- a/bumblebee/modules/battery.py +++ b/bumblebee/modules/battery.py @@ -53,14 +53,11 @@ class Module(bumblebee.engine.Module): def remaining(self): estimate = 0.0 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() - 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" except Exception: return "n/a"