diff options
| -rw-r--r-- | Plugins/Monitors/CoreCommon.hs | 13 | ||||
| -rw-r--r-- | Plugins/Monitors/CoreTemp.hs | 2 | ||||
| -rw-r--r-- | Plugins/Monitors/CpuFreq.hs | 6 | 
3 files changed, 12 insertions, 9 deletions
| diff --git a/Plugins/Monitors/CoreCommon.hs b/Plugins/Monitors/CoreCommon.hs index 95d8613..80e7700 100644 --- a/Plugins/Monitors/CoreCommon.hs +++ b/Plugins/Monitors/CoreCommon.hs @@ -27,12 +27,12 @@ import Data.List (isPrefixOf)  -- is performed.  checkedDataRetrieval :: (Num a, Ord a, Show a) =>                          String -> String -> String -> String -> (Double -> a) -                        -> Monitor String -checkedDataRetrieval failureMessage dir file pattern trans = do +                        -> (a -> String) -> Monitor String +checkedDataRetrieval failureMessage dir file pattern trans fmt = do      exists <- io $ fileExist $ concat [dir, "/", pattern, "0/", file]      case exists of           False  -> return failureMessage -         True   -> retrieveData dir file pattern trans +         True   -> retrieveData dir file pattern trans fmt  -- |  -- Function retrieves data from files in directory dir specified by @@ -40,11 +40,12 @@ checkedDataRetrieval failureMessage dir file pattern trans = do  -- to each one. Final array is processed by template parser function  -- and returned as monitor string.  retrieveData :: (Num a, Ord a, Show a) => -                String -> String -> String -> (Double -> a) -> Monitor String -retrieveData dir file pattern trans = do +                String -> String -> String -> (Double -> a) -> (a -> String) -> +                Monitor String +retrieveData dir file pattern trans fmt = do      count <- io $ dirCount dir pattern      contents <- io $ mapM getGuts $ files count -    values <- mapM (showWithColors show) $ map conversion contents +    values <- mapM (showWithColors fmt) $ map conversion contents      parseTemplate values      where          getGuts f = withFile f ReadMode hGetLine diff --git a/Plugins/Monitors/CoreTemp.hs b/Plugins/Monitors/CoreTemp.hs index 66ac637..a24b284 100644 --- a/Plugins/Monitors/CoreTemp.hs +++ b/Plugins/Monitors/CoreTemp.hs @@ -37,5 +37,5 @@ runCoreTemp _ = do          pattern = "coretemp."          divisor = 1e3 :: Double          failureMessage = "CoreTemp: N/A" -    checkedDataRetrieval failureMessage dir file pattern (/divisor) +    checkedDataRetrieval failureMessage dir file pattern (/divisor) show diff --git a/Plugins/Monitors/CpuFreq.hs b/Plugins/Monitors/CpuFreq.hs index 70482f5..fd1da4c 100644 --- a/Plugins/Monitors/CpuFreq.hs +++ b/Plugins/Monitors/CpuFreq.hs @@ -23,7 +23,7 @@ import Plugins.Monitors.CoreCommon  -- cpu frequencies.  cpuFreqConfig :: IO MConfig  cpuFreqConfig = mkMConfig -       "Freq: <cpu0>GHz" -- template +       "Freq: <cpu0>" -- template         (zipWith (++) (repeat "cpu") (map show [0 :: Int ..])) -- available                                                                -- replacements @@ -36,5 +36,7 @@ runCpuFreq _ = do          pattern = "cpu"          divisor = 1e6 :: Double          failureMessage = "CpuFreq: N/A" -    checkedDataRetrieval failureMessage dir file pattern (/divisor) +        fmt x | x < 1     = (show (round (x * 1000) :: Integer)) ++ "MHz" +              | otherwise = (show x) ++ "GHz" +    checkedDataRetrieval failureMessage dir file pattern (/divisor) fmt | 
