diff options
author | Juraj Hercek <juhe_xmonad@hck.sk> | 2009-01-28 17:18:46 +0100 |
---|---|---|
committer | Juraj Hercek <juhe_xmonad@hck.sk> | 2009-01-28 17:18:46 +0100 |
commit | 15599771fe4e52e36d7f2496a646fbffb55c7718 (patch) | |
tree | 1bb7c161bed407cfd5636c4e35176100480239b4 /Plugins/Monitors | |
parent | c024d3a6277b9539aa45424eef5c646ba02af0b5 (diff) | |
download | xmobar-15599771fe4e52e36d7f2496a646fbffb55c7718.tar.gz xmobar-15599771fe4e52e36d7f2496a646fbffb55c7718.tar.bz2 |
Workaround for ghc-6.10.1 bug + cleanup
Ignore-this: ee8d4e0e29796729d55b90eddf481af1
darcs-hash:20090128161846-69f16-a10f8397ef030ca6ee7be27a24dd6f6252361960.gz
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r-- | Plugins/Monitors/CoreCommon.hs | 12 | ||||
-rw-r--r-- | Plugins/Monitors/CpuFreq.hs | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/Plugins/Monitors/CoreCommon.hs b/Plugins/Monitors/CoreCommon.hs index d40b30a..f31ee42 100644 --- a/Plugins/Monitors/CoreCommon.hs +++ b/Plugins/Monitors/CoreCommon.hs @@ -16,6 +16,7 @@ module Plugins.Monitors.CoreCommon where import Plugins.Monitors.Common import System.Posix.Files (fileExist) +import System.IO (withFile, IOMode(ReadMode), hGetLine) import System.Directory import Data.Char (isDigit) import Data.List (isPrefixOf) @@ -26,7 +27,7 @@ import Data.List (isPrefixOf) -- is performed. checkedDataRetrieval :: String -> String -> String -> String -> Double -> Monitor String checkedDataRetrieval failureMessage dir file pattern divisor = do - exists <- io $ fileExist $ foldl (++) dir ["/", pattern, "0/", file] + exists <- io $ fileExist $ concat [dir, "/", pattern, "0/", file] case exists of False -> return failureMessage True -> retrieveData dir file pattern divisor @@ -38,15 +39,16 @@ checkedDataRetrieval failureMessage dir file pattern divisor = do retrieveData :: String -> String -> String -> Double -> Monitor String retrieveData dir file pattern divisor = do count <- io $ dirCount dir pattern - contents <- io $ mapM readFile $ files count + contents <- io $ mapM getGuts $ files count values <- mapM (showWithColors show) $ map conversion contents parseTemplate values where + getGuts file = withFile file ReadMode hGetLine dirCount path str = getDirectoryContents path >>= return . length . filter (\s -> str `isPrefixOf` s && isDigit (last s)) - files count = [ foldl (++) dir [ "/", pattern, show i, "/", file ] - | i <- [0 .. count - 1] ] - conversion = flip (/) divisor . (read :: String -> Double) + files count = map (\i -> concat [dir, "/", pattern, show i, "/", file]) + [0 .. count - 1] + conversion = (/divisor) . (read :: String -> Double) diff --git a/Plugins/Monitors/CpuFreq.hs b/Plugins/Monitors/CpuFreq.hs index 45b0c83..0cf37fb 100644 --- a/Plugins/Monitors/CpuFreq.hs +++ b/Plugins/Monitors/CpuFreq.hs @@ -25,7 +25,7 @@ cpuFreqConfig :: IO MConfig cpuFreqConfig = mkMConfig "Freq: <cpu0>GHz" -- template (zipWith (++) (repeat "cpu") (map show [0 :: Int ..])) -- available - -- replacements + -- replacements -- | -- Function retrieves monitor string holding the cpu frequency (or frequencies) |