summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2014-05-03 13:30:37 +0200
committerTomas Janousek <tomi@nomi.cz>2014-05-03 13:30:37 +0200
commit4218ab4b76e81227364ed008d8d55a8c5f3ed1a0 (patch)
tree228c00389168df2557ddf1c8ca7665a0c2d41ce9 /src
parent899f797a129fe8f81c6fb23301f2cc88120fbdc0 (diff)
downloadxmobar-4218ab4b76e81227364ed008d8d55a8c5f3ed1a0.tar.gz
xmobar-4218ab4b76e81227364ed008d8d55a8c5f3ed1a0.tar.bz2
CoreCommon: Try several paths in checkedDataRetrieval
Diffstat (limited to 'src')
-rw-r--r--src/Plugins/Monitors/CoreCommon.hs7
-rw-r--r--src/Plugins/Monitors/CoreTemp.hs2
-rw-r--r--src/Plugins/Monitors/CpuFreq.hs2
3 files changed, 6 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/CoreCommon.hs b/src/Plugins/Monitors/CoreCommon.hs
index 5d6efd4..943f491 100644
--- a/src/Plugins/Monitors/CoreCommon.hs
+++ b/src/Plugins/Monitors/CoreCommon.hs
@@ -26,10 +26,11 @@ import Plugins.Monitors.Common
import System.Directory
checkedDataRetrieval :: (Ord a, Num a)
- => String -> [String] -> Maybe (String, String -> Int)
+ => String -> [[String]] -> Maybe (String, String -> Int)
-> (Double -> a) -> (a -> String) -> Monitor String
-checkedDataRetrieval msg path lbl trans fmt = liftM (fromMaybe msg) $
- retrieveData path lbl trans fmt
+checkedDataRetrieval msg paths lbl trans fmt =
+ liftM (fromMaybe msg . listToMaybe . catMaybes) $
+ mapM (\p -> retrieveData p lbl trans fmt) paths
retrieveData :: (Ord a, Num a)
=> [String] -> Maybe (String, String -> Int)
diff --git a/src/Plugins/Monitors/CoreTemp.hs b/src/Plugins/Monitors/CoreTemp.hs
index 5109070..eebdc95 100644
--- a/src/Plugins/Monitors/CoreTemp.hs
+++ b/src/Plugins/Monitors/CoreTemp.hs
@@ -41,4 +41,4 @@ runCoreTemp _ = do
lbl = Just ("_label", read . (dropWhile (not . isDigit)))
divisor = 1e3 :: Double
show' = showDigits (max 0 dn)
- checkedDataRetrieval failureMessage path lbl (/divisor) show'
+ checkedDataRetrieval failureMessage [path] lbl (/divisor) show'
diff --git a/src/Plugins/Monitors/CpuFreq.hs b/src/Plugins/Monitors/CpuFreq.hs
index 8334d1a..3fe2577 100644
--- a/src/Plugins/Monitors/CpuFreq.hs
+++ b/src/Plugins/Monitors/CpuFreq.hs
@@ -36,4 +36,4 @@ runCpuFreq _ = do
fmt x | x < 1 = (show (round (x * 1000) :: Integer)) ++ "MHz"
| otherwise = (show x) ++ "GHz"
failureMessage <- getConfigValue naString
- checkedDataRetrieval failureMessage path Nothing (/divisor) fmt
+ checkedDataRetrieval failureMessage [path] Nothing (/divisor) fmt