diff options
Diffstat (limited to 'src/Xmobar/Plugins')
| -rw-r--r-- | src/Xmobar/Plugins/Monitors/Common/Files.hs | 9 | ||||
| -rw-r--r-- | src/Xmobar/Plugins/Monitors/CpuFreq.hs | 11 | 
2 files changed, 15 insertions, 5 deletions
| diff --git a/src/Xmobar/Plugins/Monitors/Common/Files.hs b/src/Xmobar/Plugins/Monitors/Common/Files.hs index b08fe6c..9f28d6b 100644 --- a/src/Xmobar/Plugins/Monitors/Common/Files.hs +++ b/src/Xmobar/Plugins/Monitors/Common/Files.hs @@ -14,7 +14,9 @@  --  ----------------------------------------------------------------------------- -module Xmobar.Plugins.Monitors.Common.Files (checkedDataRetrieval) where +module Xmobar.Plugins.Monitors.Common.Files ( checkedDataRetrieval +                                            , checkedDataRead) +where  #if __GLASGOW_HASKELL__ < 800  import Control.Applicative @@ -49,6 +51,11 @@ retrieveData path lbl trans fmt = do                      =<< mapM (showWithColors fmt . trans . read) pairs                    ) +checkedDataRead :: [[String]] -> Monitor [Double] +checkedDataRead paths = concat <$> mapM readData paths +  where readData path = map (read . snd) . sortBy (compare `on` fst) <$> +                         (mapM readFiles =<< findFilesAndLabel path Nothing) +  -- | Represents the different types of path components  data Comp = Fix String            | Var [String] diff --git a/src/Xmobar/Plugins/Monitors/CpuFreq.hs b/src/Xmobar/Plugins/Monitors/CpuFreq.hs index 9274cd7..d8a4319 100644 --- a/src/Xmobar/Plugins/Monitors/CpuFreq.hs +++ b/src/Xmobar/Plugins/Monitors/CpuFreq.hs @@ -22,7 +22,8 @@ import Xmobar.Plugins.Monitors.Common  -- get more cpu frequencies.  cpuFreqConfig :: IO MConfig  cpuFreqConfig = -  mkMConfig "Freq: <cpu0>" (map ((++) "cpu" . show) [0 :: Int ..]) +  mkMConfig "Freq: <cpu0>" +            (["max", "min", "avg"] ++ map ((++) "cpu" . show) [0 :: Int ..])  -- | @@ -32,12 +33,14 @@ runCpuFreq :: [String] -> Monitor String  runCpuFreq _ = do    suffix <- getConfigValue useSuffix    ddigits <- getConfigValue decDigits -  let path = ["/sys/devices/system/cpu/cpu", "/cpufreq/scaling_cur_freq"] +  let paths = ["/sys/devices/system/cpu/cpu", "/cpufreq/scaling_cur_freq"]        divisor = 1e6 :: Double        fmt x | x < 1 = if suffix then mhzFmt x ++ "MHz"                                  else ghzFmt x              | otherwise = ghzFmt x ++ if suffix then "GHz" else ""        mhzFmt x = show (round (x * 1000) :: Integer)        ghzFmt = showDigits ddigits -  failureMessage <- getConfigValue naString -  checkedDataRetrieval failureMessage [path] Nothing (/divisor) fmt +      sts xs = [maximum xs, minimum xs, sum xs / fromIntegral (length xs)] +  vs <- checkedDataRead [paths] +  if null vs then getConfigValue naString +  else mapM (showWithColors fmt . (/divisor)) (sts vs ++ vs) >>= parseTemplate | 
