diff options
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r-- | src/Plugins/Monitors/Batt.hs | 36 | ||||
-rw-r--r-- | src/Plugins/Monitors/Bright.hs | 12 | ||||
-rw-r--r-- | src/Plugins/Monitors/Common.hs | 26 | ||||
-rw-r--r-- | src/Plugins/Monitors/Cpu.hs | 12 | ||||
-rw-r--r-- | src/Plugins/Monitors/Disk.hs | 58 | ||||
-rw-r--r-- | src/Plugins/Monitors/MPD.hs | 14 | ||||
-rw-r--r-- | src/Plugins/Monitors/Mem.hs | 24 | ||||
-rw-r--r-- | src/Plugins/Monitors/MultiCpu.hs | 24 | ||||
-rw-r--r-- | src/Plugins/Monitors/Net.hs | 32 | ||||
-rw-r--r-- | src/Plugins/Monitors/Volume.hs | 20 | ||||
-rw-r--r-- | src/Plugins/Monitors/Wireless.hs | 14 |
11 files changed, 136 insertions, 136 deletions
diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index 592deae..f7b31e4 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -34,9 +34,9 @@ data BattOpts = BattOpts , highThreshold :: Float , onlineFile :: FilePath , scale :: Float - , onDynamicString :: Maybe DynamicString - , offDynamicString :: Maybe DynamicString - , idleDynamicString :: Maybe DynamicString + , onIconPattern :: Maybe IconPattern + , offIconPattern :: Maybe IconPattern + , idleIconPattern :: Maybe IconPattern } defaultOpts :: BattOpts @@ -52,9 +52,9 @@ defaultOpts = BattOpts , highThreshold = -10 , onlineFile = "AC/online" , scale = 1e6 - , onDynamicString = Nothing - , offDynamicString = Nothing - , idleDynamicString = Nothing + , onIconPattern = Nothing + , offIconPattern = Nothing + , idleIconPattern = Nothing } options :: [OptDescr (BattOpts -> BattOpts)] @@ -70,12 +70,12 @@ options = , Option "H" ["hight"] (ReqArg (\x o -> o { highThreshold = read x }) "") "" , Option "f" ["online"] (ReqArg (\x o -> o { onlineFile = x }) "") "" , Option "s" ["scale"] (ReqArg (\x o -> o {scale = read x}) "") "" - , Option "" ["on-dynamic-string"] (ReqArg (\x o -> - o { onDynamicString = Just $ parseDynamicString x }) "") "" - , Option "" ["off-dynamic-string"] (ReqArg (\x o -> - o { offDynamicString = Just $ parseDynamicString x }) "") "" - , Option "" ["idle-dynamic-string"] (ReqArg (\x o -> - o { idleDynamicString = Just $ parseDynamicString x }) "") "" + , Option "" ["on-icon-pattern"] (ReqArg (\x o -> + o { onIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["off-icon-pattern"] (ReqArg (\x o -> + o { offIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["idle-icon-pattern"] (ReqArg (\x o -> + o { idleIconPattern = Just $ parseIconPattern x }) "") "" ] parseOpts :: [String] -> IO BattOpts @@ -94,7 +94,7 @@ sysDir = "/sys/class/power_supply" battConfig :: IO MConfig battConfig = mkMConfig "Batt: <watts>, <left>% / <timeleft>" -- template - ["leftbar", "leftvbar", "left", "acstatus", "timeleft", "watts", "leftdstr"] -- replacements + ["leftbar", "leftvbar", "left", "acstatus", "timeleft", "watts", "leftipat"] -- replacements data Files = Files { fFull :: String @@ -182,7 +182,7 @@ runBatt' bfs args = do Result x w t s -> do l <- fmtPercent x ws <- fmtWatts w opts suffix d - si <- getDynamicString opts s x + si <- getIconPattern opts s x parseTemplate (l ++ [fmtStatus opts s, fmtTime $ floor t, ws, si]) NA -> getConfigValue naString where fmtPercent :: Float -> Monitor [String] @@ -209,9 +209,9 @@ runBatt' bfs args = do | -x >= highThreshold o = maybeColor (highWColor o) | -x >= lowThreshold o = maybeColor (mediumWColor o) | otherwise = maybeColor (lowWColor o) - getDynamicString opts status x = do + getIconPattern opts status x = do let x' = minimum [1, x] case status of - Idle -> showDynamicString (idleDynamicString opts) x' - Charging -> showDynamicString (onDynamicString opts) x' - Discharging -> showDynamicString (offDynamicString opts) x' + Idle -> showIconPattern (idleIconPattern opts) x' + Charging -> showIconPattern (onIconPattern opts) x' + Discharging -> showIconPattern (offIconPattern opts) x' diff --git a/src/Plugins/Monitors/Bright.hs b/src/Plugins/Monitors/Bright.hs index 999b459..cb510f6 100644 --- a/src/Plugins/Monitors/Bright.hs +++ b/src/Plugins/Monitors/Bright.hs @@ -26,22 +26,22 @@ import Plugins.Monitors.Common data BrightOpts = BrightOpts { subDir :: String , currBright :: String , maxBright :: String - , curBrightDynamicString :: Maybe DynamicString + , curBrightIconPattern :: Maybe IconPattern } defaultOpts :: BrightOpts defaultOpts = BrightOpts { subDir = "acpi_video0" , currBright = "actual_brightness" , maxBright = "max_brightness" - , curBrightDynamicString = Nothing + , curBrightIconPattern = Nothing } options :: [OptDescr (BrightOpts -> BrightOpts)] options = [ Option "D" ["device"] (ReqArg (\x o -> o { subDir = x }) "") "" , Option "C" ["curr"] (ReqArg (\x o -> o { currBright = x }) "") "" , Option "M" ["max"] (ReqArg (\x o -> o { maxBright = x }) "") "" - , Option "" ["brightness-dynamic-string"] (ReqArg (\x o -> - o { curBrightDynamicString = Just $ parseDynamicString x }) "") "" + , Option "" ["brightness-icon-pattern"] (ReqArg (\x o -> + o { curBrightIconPattern = Just $ parseIconPattern x }) "") "" ] -- from Batt.hs @@ -56,7 +56,7 @@ sysDir = "/sys/class/backlight/" brightConfig :: IO MConfig brightConfig = mkMConfig "<percent>" -- template - ["vbar", "percent", "bar", "dstr"] -- replacements + ["vbar", "percent", "bar", "ipat"] -- replacements data Files = Files { fCurr :: String , fMax :: String @@ -85,7 +85,7 @@ runBright args = do fmtPercent opts c = do r <- showVerticalBar (100 * c) c s <- showPercentWithColors c t <- showPercentBar (100 * c) c - d <- showDynamicString (curBrightDynamicString opts) c + d <- showIconPattern (curBrightIconPattern opts) c return [r,s,t,d] readBright :: Files -> IO Float diff --git a/src/Plugins/Monitors/Common.hs b/src/Plugins/Monitors/Common.hs index ed91c73..7d11258 100644 --- a/src/Plugins/Monitors/Common.hs +++ b/src/Plugins/Monitors/Common.hs @@ -40,8 +40,8 @@ module Plugins.Monitors.Common ( , parseTemplate' -- ** String Manipulation -- $strings - , DynamicString - , parseDynamicString + , IconPattern + , parseIconPattern , padString , showWithPadding , showWithColors @@ -50,10 +50,10 @@ module Plugins.Monitors.Common ( , showPercentsWithColors , showPercentBar , showVerticalBar - , showDynamicString + , showIconPattern , showLogBar , showLogVBar - , showLogDynamicString + , showLogIconPattern , showWithUnits , takeDigits , showDigits @@ -352,10 +352,10 @@ combine m ((s,ts,ss):xs) = -- $strings -type DynamicString = Int -> String +type IconPattern = Int -> String -parseDynamicString :: String -> DynamicString -parseDynamicString path = +parseIconPattern :: String -> IconPattern +parseIconPattern path = let spl = splitOnPercent path in \i -> concat $ intersperse (show i) spl where splitOnPercent [] = [[]] @@ -469,9 +469,9 @@ showPercentBar v x = do s <- colorizeString v (take len $ cycle bf) return $ s ++ take (bw - len) (cycle bb) -showDynamicString :: Maybe DynamicString -> Float -> Monitor String -showDynamicString Nothing _ = return "" -showDynamicString (Just str) x = return $ str $ convert $ 100 * x +showIconPattern :: Maybe IconPattern -> Float -> Monitor String +showIconPattern Nothing _ = return "" +showIconPattern (Just str) x = return $ str $ convert $ 100 * x where convert val | t <= 0 = 0 | t > 8 = 8 @@ -511,8 +511,8 @@ showLogVBar f v = do | otherwise = f + logBase 2 (x / hh) / bw showVerticalBar v $ choose v -showLogDynamicString :: Maybe DynamicString -> Float -> Float -> Monitor String -showLogDynamicString str f v = do +showLogIconPattern :: Maybe IconPattern -> Float -> Float -> Monitor String +showLogIconPattern str f v = do h <- fromIntegral `fmap` getConfigValue high l <- fromIntegral `fmap` getConfigValue low bw <- fromIntegral `fmap` getConfigValue barWidth @@ -520,4 +520,4 @@ showLogDynamicString str f v = do choose x | x == 0.0 = 0 | x <= ll = 1 / bw | otherwise = f + logBase 2 (x / hh) / bw - showDynamicString str $ choose v + showIconPattern str $ choose v diff --git a/src/Plugins/Monitors/Cpu.hs b/src/Plugins/Monitors/Cpu.hs index 5abde7e..7fed989 100644 --- a/src/Plugins/Monitors/Cpu.hs +++ b/src/Plugins/Monitors/Cpu.hs @@ -21,18 +21,18 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef) import System.Console.GetOpt data CpuOpts = CpuOpts - { loadDynamicString :: Maybe DynamicString + { loadIconPattern :: Maybe IconPattern } defaultOpts :: CpuOpts defaultOpts = CpuOpts - { loadDynamicString = Nothing + { loadIconPattern = Nothing } options :: [OptDescr (CpuOpts -> CpuOpts)] options = - [ Option "" ["load-dynamic-string"] (ReqArg (\x o -> - o { loadDynamicString = Just $ parseDynamicString x }) "") "" + [ Option "" ["load-icon-pattern"] (ReqArg (\x o -> + o { loadIconPattern = Just $ parseIconPattern x }) "") "" ] parseOpts :: [String] -> IO CpuOpts @@ -44,7 +44,7 @@ parseOpts argv = cpuConfig :: IO MConfig cpuConfig = mkMConfig "Cpu: <total>%" - ["bar","vbar","dstr","total","user","nice","system","idle","iowait"] + ["bar","vbar","ipat","total","user","nice","system","idle","iowait"] type CpuDataRef = IORef [Int] @@ -70,7 +70,7 @@ formatCpu opts xs = do let t = sum $ take 3 xs b <- showPercentBar (100 * t) t v <- showVerticalBar (100 * t) t - d <- showDynamicString (loadDynamicString opts) t + d <- showIconPattern (loadIconPattern opts) t ps <- showPercentsWithColors (t:xs) return (b:v:d:ps) diff --git a/src/Plugins/Monitors/Disk.hs b/src/Plugins/Monitors/Disk.hs index e020c85..0019c1a 100644 --- a/src/Plugins/Monitors/Disk.hs +++ b/src/Plugins/Monitors/Disk.hs @@ -28,9 +28,9 @@ import System.Directory (canonicalizePath, doesFileExist) import System.Console.GetOpt data DiskIOOpts = DiskIOOpts - { totalDynamicString :: Maybe DynamicString - , writeDynamicString :: Maybe DynamicString - , readDynamicString :: Maybe DynamicString + { totalIconPattern :: Maybe IconPattern + , writeIconPattern :: Maybe IconPattern + , readIconPattern :: Maybe IconPattern } parseDiskIOOpts :: [String] -> IO DiskIOOpts @@ -39,29 +39,29 @@ parseDiskIOOpts argv = (o, _, []) -> return $ foldr id defaultOpts o (_, _, errs) -> ioError . userError $ concat errs where defaultOpts = DiskIOOpts - { totalDynamicString = Nothing - , writeDynamicString = Nothing - , readDynamicString = Nothing + { totalIconPattern = Nothing + , writeIconPattern = Nothing + , readIconPattern = Nothing } options = - [ Option "" ["total-dynamic-string"] (ReqArg (\x o -> - o { totalDynamicString = Just $ parseDynamicString x}) "") "" - , Option "" ["write-dynamic-string"] (ReqArg (\x o -> - o { writeDynamicString = Just $ parseDynamicString x}) "") "" - , Option "" ["read-dynamic-string"] (ReqArg (\x o -> - o { readDynamicString = Just $ parseDynamicString x}) "") "" + [ Option "" ["total-icon-pattern"] (ReqArg (\x o -> + o { totalIconPattern = Just $ parseIconPattern x}) "") "" + , Option "" ["write-icon-pattern"] (ReqArg (\x o -> + o { writeIconPattern = Just $ parseIconPattern x}) "") "" + , Option "" ["read-icon-pattern"] (ReqArg (\x o -> + o { readIconPattern = Just $ parseIconPattern x}) "") "" ] diskIOConfig :: IO MConfig diskIOConfig = mkMConfig "" ["total", "read", "write" ,"totalbar", "readbar", "writebar" ,"totalvbar", "readvbar", "writevbar" - ,"totaldstr", "readdstr", "writedstr" + ,"totalipat", "readipat", "writeipat" ] data DiskUOpts = DiskUOpts - { freeDynamicString :: Maybe DynamicString - , usedDynamicString :: Maybe DynamicString + { freeIconPattern :: Maybe IconPattern + , usedIconPattern :: Maybe IconPattern } parseDiskUOpts :: [String] -> IO DiskUOpts @@ -70,21 +70,21 @@ parseDiskUOpts argv = (o, _, []) -> return $ foldr id defaultOpts o (_, _, errs) -> ioError . userError $ concat errs where defaultOpts = DiskUOpts - { freeDynamicString = Nothing - , usedDynamicString = Nothing + { freeIconPattern = Nothing + , usedIconPattern = Nothing } options = - [ Option "" ["free-dynamic-string"] (ReqArg (\x o -> - o { freeDynamicString = Just $ parseDynamicString x}) "") "" - , Option "" ["used-dynamic-string"] (ReqArg (\x o -> - o { usedDynamicString = Just $ parseDynamicString x}) "") "" + [ Option "" ["free-icon-pattern"] (ReqArg (\x o -> + o { freeIconPattern = Just $ parseIconPattern x}) "") "" + , Option "" ["used-icon-pattern"] (ReqArg (\x o -> + o { usedIconPattern = Just $ parseIconPattern x}) "") "" ] diskUConfig :: IO MConfig diskUConfig = mkMConfig "" [ "size", "free", "used", "freep", "usedp" - , "freebar", "freevbar", "freedstr" - , "usedbar", "usedvbar", "useddstr" + , "freebar", "freevbar", "freeipat" + , "usedbar", "usedvbar", "usedipat" ] type DevName = String @@ -183,10 +183,10 @@ runDiskIO' opts (tmp, xs) = do s <- mapM (showWithColors speedToStr) xs b <- mapM (showLogBar 0.8) xs vb <- mapM (showLogVBar 0.8) xs - dstr <- mapM (\(f,v) -> showLogDynamicString (f opts) 0.8 v) - $ zip [totalDynamicString, readDynamicString, writeDynamicString] xs + ipat <- mapM (\(f,v) -> showLogIconPattern (f opts) 0.8 v) + $ zip [totalIconPattern, readIconPattern, writeIconPattern] xs setConfigValue tmp template - parseTemplate $ s ++ b ++ vb ++ dstr + parseTemplate $ s ++ b ++ vb ++ ipat runDiskIO :: DevDataRef -> [(String, String)] -> [String] -> Monitor String runDiskIO dref disks argv = do @@ -225,11 +225,11 @@ runDiskU' opts tmp path = do sp <- showPercentsWithColors [fr, 1 - fr] fb <- showPercentBar (fromIntegral freep) fr fvb <- showVerticalBar (fromIntegral freep) fr - fdstr <- showDynamicString (freeDynamicString opts) fr + fipat <- showIconPattern (freeIconPattern opts) fr ub <- showPercentBar (fromIntegral $ 100 - freep) (1 - fr) uvb <- showVerticalBar (fromIntegral $ 100 - freep) (1 - fr) - udstr <- showDynamicString (usedDynamicString opts) (1 - fr) - parseTemplate $ [sizeToStr total] ++ s ++ sp ++ [fb,fvb,fdstr,ub,uvb,udstr] + uipat <- showIconPattern (usedIconPattern opts) (1 - fr) + parseTemplate $ [sizeToStr total] ++ s ++ sp ++ [fb,fvb,fipat,ub,uvb,uipat] where ign = const (return [0, 0, 0]) :: SomeException -> IO [Integer] diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs index 3c1615e..1a49ad3 100644 --- a/src/Plugins/Monitors/MPD.hs +++ b/src/Plugins/Monitors/MPD.hs @@ -22,7 +22,7 @@ import Control.Concurrent (threadDelay) mpdConfig :: IO MConfig mpdConfig = mkMConfig "MPD: <state>" - [ "bar", "vbar", "dstr", "state", "statei", "volume", "length" + [ "bar", "vbar", "ipat", "state", "statei", "volume", "length" , "lapsed", "remaining", "plength", "ppos", "file" , "name", "artist", "composer", "performer" , "album", "title", "track", "genre" @@ -32,7 +32,7 @@ data MOpts = MOpts { mPlaying :: String , mStopped :: String , mPaused :: String - , mLapsedDynamicString :: Maybe DynamicString + , mLapsedIconPattern :: Maybe IconPattern } defaultOpts :: MOpts @@ -40,7 +40,7 @@ defaultOpts = MOpts { mPlaying = ">>" , mStopped = "><" , mPaused = "||" - , mLapsedDynamicString = Nothing + , mLapsedIconPattern = Nothing } options :: [OptDescr (MOpts -> MOpts)] @@ -48,8 +48,8 @@ options = [ Option "P" ["playing"] (ReqArg (\x o -> o { mPlaying = x }) "") "" , Option "S" ["stopped"] (ReqArg (\x o -> o { mStopped = x }) "") "" , Option "Z" ["paused"] (ReqArg (\x o -> o { mPaused = x }) "") "" - , Option "" ["lapsed-dynamic-string"] (ReqArg (\x o -> - o { mLapsedDynamicString = Just $ parseDynamicString x }) "") "" + , Option "" ["lapsed-icon-pattern"] (ReqArg (\x o -> + o { mLapsedIconPattern = Just $ parseIconPattern x }) "") "" ] runMPD :: [String] -> Monitor String @@ -91,8 +91,8 @@ parseMPD (Right st) song opts = do songData <- parseSong song bar <- showPercentBar (100 * b) b vbar <- showVerticalBar (100 * b) b - dstr <- showDynamicString (mLapsedDynamicString opts) b - return $ [bar, vbar, dstr, ss, si, vol, len, lap, remain, plen, ppos] ++ songData + ipat <- showIconPattern (mLapsedIconPattern opts) b + return $ [bar, vbar, ipat, ss, si, vol, len, lap, remain, plen, ppos] ++ songData where s = M.stState st ss = show s si = stateGlyph s opts diff --git a/src/Plugins/Monitors/Mem.hs b/src/Plugins/Monitors/Mem.hs index 7524989..b19c5a7 100644 --- a/src/Plugins/Monitors/Mem.hs +++ b/src/Plugins/Monitors/Mem.hs @@ -19,22 +19,22 @@ import qualified Data.Map as M import System.Console.GetOpt data MemOpts = MemOpts - { usedDynamicString :: Maybe DynamicString - , freeDynamicString :: Maybe DynamicString + { usedIconPattern :: Maybe IconPattern + , freeIconPattern :: Maybe IconPattern } defaultOpts :: MemOpts defaultOpts = MemOpts - { usedDynamicString = Nothing - , freeDynamicString = Nothing + { usedIconPattern = Nothing + , freeIconPattern = Nothing } options :: [OptDescr (MemOpts -> MemOpts)] options = - [ Option "" ["used-dynamic-string"] (ReqArg (\x o -> - o { usedDynamicString = Just $ parseDynamicString x }) "") "" - , Option "" ["free-dynamic-string"] (ReqArg (\x o -> - o { freeDynamicString = Just $ parseDynamicString x }) "") "" + [ Option "" ["used-icon-pattern"] (ReqArg (\x o -> + o { usedIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["free-icon-pattern"] (ReqArg (\x o -> + o { freeIconPattern = Just $ parseIconPattern x }) "") "" ] parseOpts :: [String] -> IO MemOpts @@ -46,7 +46,7 @@ parseOpts argv = memConfig :: IO MConfig memConfig = mkMConfig "Mem: <usedratio>% (<cache>M)" -- template - ["usedbar", "usedvbar", "useddstr", "freebar", "freevbar", "freedstr", "usedratio", "freeratio", + ["usedbar", "usedvbar", "usedipat", "freebar", "freevbar", "freeipat", "usedratio", "freeratio", "total", "free", "buffer", "cache", "rest", "used"] -- available replacements fileMEM :: IO String @@ -76,14 +76,14 @@ formatMem opts (r:fr:xs) = rr = 100 * r ub <- showPercentBar rr r uvb <- showVerticalBar rr r - udstr <- showDynamicString (usedDynamicString opts) r + uipat <- showIconPattern (usedIconPattern opts) r fb <- showPercentBar (100 - rr) (1 - r) fvb <- showVerticalBar (100 - rr) ( 1 - r) - fdstr <- showDynamicString (freeDynamicString opts) (1 - r) + fipat <- showIconPattern (freeIconPattern opts) (1 - r) rs <- showPercentWithColors r fs <- showPercentWithColors fr s <- mapM (showWithColors f) xs - return (ub:uvb:udstr:fb:fvb:fdstr:rs:fs:s) + return (ub:uvb:uipat:fb:fvb:fipat:rs:fs:s) formatMem _ _ = replicate 10 `fmap` getConfigValue naString runMem :: [String] -> Monitor String diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs index 9f8c191..eab21da 100644 --- a/src/Plugins/Monitors/MultiCpu.hs +++ b/src/Plugins/Monitors/MultiCpu.hs @@ -22,22 +22,22 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef) import System.Console.GetOpt data MultiCpuOpts = MultiCpuOpts - { loadDynamicStrings :: [DynamicString] - , loadDynamicString :: Maybe DynamicString + { loadIconPatterns :: [IconPattern] + , loadIconPattern :: Maybe IconPattern } defaultOpts :: MultiCpuOpts defaultOpts = MultiCpuOpts - { loadDynamicStrings = [] - , loadDynamicString = Nothing + { loadIconPatterns = [] + , loadIconPattern = Nothing } options :: [OptDescr (MultiCpuOpts -> MultiCpuOpts)] options = - [ Option "" ["load-dynamic-string"] (ReqArg (\x o -> - o { loadDynamicString = Just $ parseDynamicString x }) "") "" - , Option "" ["load-dynamic-strings"] (ReqArg (\x o -> - o { loadDynamicStrings = parseDynamicString x : loadDynamicStrings o }) "") "" + [ Option "" ["load-icon-pattern"] (ReqArg (\x o -> + o { loadIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["load-icon-patterns"] (ReqArg (\x o -> + o { loadIconPatterns = parseIconPattern x : loadIconPatterns o }) "") "" ] parseOpts :: [String] -> IO MultiCpuOpts @@ -47,7 +47,7 @@ parseOpts argv = (_, _, errs) -> ioError . userError $ concat errs variables :: [String] -variables = ["bar", "vbar","dstr","total","user","nice","system","idle"] +variables = ["bar", "vbar","ipat","total","user","nice","system","idle"] vNum :: Int vNum = length variables @@ -91,12 +91,12 @@ formatCpu opts i xs | otherwise = let t = sum $ take 3 xs in do b <- showPercentBar (100 * t) t h <- showVerticalBar (100 * t) t - d <- showDynamicString tryString t + d <- showIconPattern tryString t ps <- showPercentsWithColors (t:xs) return (b:h:d:ps) where tryString - | i == 0 = loadDynamicString opts - | i <= length (loadDynamicStrings opts) = Just $ (loadDynamicStrings opts) !! (i - 1) + | i == 0 = loadIconPattern opts + | i <= length (loadIconPatterns opts) = Just $ (loadIconPatterns opts) !! (i - 1) | otherwise = Nothing splitEvery :: (Eq a) => Int -> [a] -> [[a]] diff --git a/src/Plugins/Monitors/Net.hs b/src/Plugins/Monitors/Net.hs index 137770c..5954a77 100644 --- a/src/Plugins/Monitors/Net.hs +++ b/src/Plugins/Monitors/Net.hs @@ -30,22 +30,22 @@ import System.Console.GetOpt import qualified Data.ByteString.Lazy.Char8 as B data NetOpts = NetOpts - { rxDynamicString :: Maybe DynamicString - , txDynamicString :: Maybe DynamicString + { rxIconPattern :: Maybe IconPattern + , txIconPattern :: Maybe IconPattern } defaultOpts :: NetOpts defaultOpts = NetOpts - { rxDynamicString = Nothing - , txDynamicString = Nothing + { rxIconPattern = Nothing + , txIconPattern = Nothing } options :: [OptDescr (NetOpts -> NetOpts)] options = - [ Option "" ["rx-dynamic-string"] (ReqArg (\x o -> - o { rxDynamicString = Just $ parseDynamicString x }) "") "" - , Option "" ["tx-dynamic-string"] (ReqArg (\x o -> - o { txDynamicString = Just $ parseDynamicString x }) "") "" + [ Option "" ["rx-icon-pattern"] (ReqArg (\x o -> + o { rxIconPattern = Just $ parseIconPattern x }) "") "" + , Option "" ["tx-icon-pattern"] (ReqArg (\x o -> + o { txIconPattern = Just $ parseIconPattern x }) "") "" ] parseOpts :: [String] -> IO NetOpts @@ -88,7 +88,7 @@ instance Ord NetDev where netConfig :: IO MConfig netConfig = mkMConfig "<dev>: <rx>KB|<tx>KB" -- template - ["dev", "rx", "tx", "rxbar", "rxvbar", "rxdstr", "txbar", "txvbar", "txdstr"] -- available replacements + ["dev", "rx", "tx", "rxbar", "rxvbar", "rxipat", "txbar", "txvbar", "txipat"] -- available replacements operstateDir :: String -> FilePath operstateDir d = "/sys/class/net" </> d </> "operstate" @@ -132,8 +132,8 @@ findNetDev dev = do isDev (NI d) = d == dev isDev NA = False -formatNet :: Maybe DynamicString -> Float -> Monitor (String, String, String, String) -formatNet mdstr d = do +formatNet :: Maybe IconPattern -> Float -> Monitor (String, String, String, String) +formatNet mipat d = do s <- getConfigValue useSuffix dd <- getConfigValue decDigits let str True v = showDigits dd d' ++ show u @@ -141,17 +141,17 @@ formatNet mdstr d = do str False v = showDigits dd $ v / 1024 b <- showLogBar 0.9 d vb <- showLogVBar 0.9 d - dstr <- showLogDynamicString mdstr 0.9 d + ipat <- showLogIconPattern mipat 0.9 d x <- showWithColors (str s) d - return (x, b, vb, dstr) + return (x, b, vb, ipat) printNet :: NetOpts -> NetDev -> Monitor String printNet opts nd = case nd of ND d r t -> do - (rx, rb, rvb, rdstr) <- formatNet (rxDynamicString opts) r - (tx, tb, tvb, tdstr) <- formatNet (txDynamicString opts) t - parseTemplate [d,rx,tx,rb,rvb,rdstr,tb,tvb,tdstr] + (rx, rb, rvb, ripat) <- formatNet (rxIconPattern opts) r + (tx, tb, tvb, tipat) <- formatNet (txIconPattern opts) t + parseTemplate [d,rx,tx,rb,rvb,ripat,tb,tvb,tipat] NI _ -> return "" NA -> getConfigValue naString diff --git a/src/Plugins/Monitors/Volume.hs b/src/Plugins/Monitors/Volume.hs index 2787a3c..8c39b9f 100644 --- a/src/Plugins/Monitors/Volume.hs +++ b/src/Plugins/Monitors/Volume.hs @@ -24,7 +24,7 @@ import System.Console.GetOpt volumeConfig :: IO MConfig volumeConfig = mkMConfig "Vol: <volume>% <status>" - ["volume", "volumebar", "volumevbar", "dB","status", "volumedstr"] + ["volume", "volumebar", "volumevbar", "dB","status", "volumeipat"] data VolumeOpts = VolumeOpts @@ -34,7 +34,7 @@ data VolumeOpts = VolumeOpts , offColor :: Maybe String , highDbThresh :: Float , lowDbThresh :: Float - , volumeDynamicString :: Maybe DynamicString + , volumeIconPattern :: Maybe IconPattern } defaultOpts :: VolumeOpts @@ -45,7 +45,7 @@ defaultOpts = VolumeOpts , offColor = Just "red" , highDbThresh = -5.0 , lowDbThresh = -30.0 - , volumeDynamicString = Nothing + , volumeIconPattern = Nothing } options :: [OptDescr (VolumeOpts -> VolumeOpts)] @@ -56,8 +56,8 @@ options = , Option "" ["highd"] (ReqArg (\x o -> o { highDbThresh = read x }) "") "" , Option "C" ["onc"] (ReqArg (\x o -> o { onColor = Just x }) "") "" , Option "c" ["offc"] (ReqArg (\x o -> o { offColor = Just x }) "") "" - , Option "" ["volume-dynamic-string"] (ReqArg (\x o -> - o { volumeDynamicString = Just $ parseDynamicString x }) "") "" + , Option "" ["volume-icon-pattern"] (ReqArg (\x o -> + o { volumeIconPattern = Just $ parseIconPattern x }) "") "" ] parseOpts :: [String] -> IO VolumeOpts @@ -84,9 +84,9 @@ formatVolVBar :: Integer -> Integer -> Integer -> Monitor String formatVolVBar lo hi v = showVerticalBar (100 * x) x where x = percent v lo hi -formatVolDStr :: Maybe DynamicString -> Integer -> Integer -> Integer -> Monitor String -formatVolDStr dstr lo hi v = - showDynamicString dstr $ percent v lo hi +formatVolDStr :: Maybe IconPattern -> Integer -> Integer -> Integer -> Monitor String +formatVolDStr ipat lo hi v = + showIconPattern ipat $ percent v lo hi switchHelper :: VolumeOpts -> (VolumeOpts -> Maybe String) @@ -134,8 +134,8 @@ runVolume mixerName controlName argv = do v <- liftMonitor $ liftM3 formatVolVBar lo hi val d <- getFormatDB opts db s <- getFormatSwitch opts sw - dstr <- liftMonitor $ liftM3 (formatVolDStr $ volumeDynamicString opts) lo hi val - parseTemplate [p, b, v, d, s, dstr] + ipat <- liftMonitor $ liftM3 (formatVolDStr $ volumeIconPattern opts) lo hi val + parseTemplate [p, b, v, d, s, ipat] where diff --git a/src/Plugins/Monitors/Wireless.hs b/src/Plugins/Monitors/Wireless.hs index c87bec6..b1e3c7e 100644 --- a/src/Plugins/Monitors/Wireless.hs +++ b/src/Plugins/Monitors/Wireless.hs @@ -20,18 +20,18 @@ import Plugins.Monitors.Common import IWlib data WirelessOpts = WirelessOpts - { qualityDynamicString :: Maybe DynamicString + { qualityIconPattern :: Maybe IconPattern } defaultOpts :: WirelessOpts defaultOpts = WirelessOpts - { qualityDynamicString = Nothing + { qualityIconPattern = Nothing } options :: [OptDescr (WirelessOpts -> WirelessOpts)] options = - [ Option "" ["quality-dynamic-string"] (ReqArg (\d opts -> - opts { qualityDynamicString = Just $ parseDynamicString d }) "") "" + [ Option "" ["quality-icon-pattern"] (ReqArg (\d opts -> + opts { qualityIconPattern = Just $ parseIconPattern d }) "") "" ] parseOpts :: [String] -> IO WirelessOpts @@ -42,7 +42,7 @@ parseOpts argv = wirelessConfig :: IO MConfig wirelessConfig = - mkMConfig "<essid> <quality>" ["essid", "quality", "qualitybar", "qualityvbar", "qualitydstr"] + mkMConfig "<essid> <quality>" ["essid", "quality", "qualitybar", "qualityvbar", "qualityipat"] runWireless :: String -> [String] -> Monitor String runWireless iface args = do @@ -58,5 +58,5 @@ runWireless iface args = do else showWithPadding "" qb <- showPercentBar qlty (qlty / 100) qvb <- showVerticalBar qlty (qlty / 100) - qdstr <- showDynamicString (qualityDynamicString opts) (qlty / 100) - parseTemplate [ep, q, qb, qvb, qdstr] + qipat <- showIconPattern (qualityIconPattern opts) (qlty / 100) + parseTemplate [ep, q, qb, qvb, qipat] |