summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/Batt.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2011-02-13 03:18:31 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2011-02-13 03:18:31 +0100
commit5241b9a717f34cabe762c8e180cfc9adf052eabc (patch)
tree6050a7d7c6158fc60257a599f8c024f2cf116672 /src/Plugins/Monitors/Batt.hs
parent2821ab1ad61d5fd4c8d15cab50c69503419cb892 (diff)
downloadxmobar-5241b9a717f34cabe762c8e180cfc9adf052eabc.tar.gz
xmobar-5241b9a717f34cabe762c8e180cfc9adf052eabc.tar.bz2
Battery: use power_now if current_now is not available (issue 40)
Diffstat (limited to 'src/Plugins/Monitors/Batt.hs')
-rw-r--r--src/Plugins/Monitors/Batt.hs18
1 files changed, 10 insertions, 8 deletions
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 <jao@gnu.org>
@@ -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