From 5241b9a717f34cabe762c8e180cfc9adf052eabc Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 13 Feb 2011 03:18:31 +0100 Subject: Battery: use power_now if current_now is not available (issue 40) --- src/Plugins/Monitors/Batt.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Plugins/Monitors/Batt.hs') diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index c9ea220..7d4242a 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -1,8 +1,8 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt --- Copyright : (c) 2010 Andrea Rossato, Petr Rockai --- (c) 2010, 2011 Jose A Ortega +-- Copyright : (c) 2010, 2011 Jose A Ortega +-- (c) 2010 Andrea Rossato, Petr Rockai -- License : BSD-style (see LICENSE) -- -- Maintainer : Jose A. Ortega Ruiz @@ -93,15 +93,17 @@ batteryFiles :: String -> IO Files batteryFiles bat = do is_charge <- fileExist $ prefix "charge_now" is_energy <- fileExist $ prefix "energy_now" + is_current <- fileExist $ prefix "current_now" + let cf = if is_current then "current_now" else "power_now" return $ case (is_charge, is_energy) of - (True, _) -> files "charge" - (_, True) -> files "energy" + (True, _) -> files "charge" cf + (_, True) -> files "energy" cf _ -> NoFiles where prefix = sysDir bat - files ch = Files { fFull = prefix ch ++ "_full" - , fNow = prefix ch ++ "_now" - , fCurrent = prefix "current_now" - , fVoltage = prefix "voltage_now" } + files ch cf = Files { fFull = prefix ch ++ "_full" + , fNow = prefix ch ++ "_now" + , fCurrent = prefix cf + , fVoltage = prefix "voltage_now" } haveAc :: FilePath -> IO Bool haveAc f = do -- cgit v1.2.3