diff options
author | Alexander Shabalin <shabalyn.a@gmail.com> | 2014-09-07 22:24:00 +0400 |
---|---|---|
committer | Alexander Shabalin <shabalyn.a@gmail.com> | 2014-09-14 12:03:48 +0400 |
commit | e590f14593728b8afc2b77e8be356e5c06428107 (patch) | |
tree | 7a316e70cc1c7ae84499516f61579f755b7dce0a /src/Plugins/Monitors/Volume.hs | |
parent | e8e4415b7eba49d2d6ddb18ab13b3151c9a787bd (diff) | |
download | xmobar-e590f14593728b8afc2b77e8be356e5c06428107.tar.gz xmobar-e590f14593728b8afc2b77e8be356e5c06428107.tar.bz2 |
Implement DynamicString for Monitors supporting vbar.
* Batt
* Bright
* Cpu
* Disk
* MPD
* Mem
* MultiCpu
* Net
* Volume
* Wireless
Diffstat (limited to 'src/Plugins/Monitors/Volume.hs')
-rw-r--r-- | src/Plugins/Monitors/Volume.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Plugins/Monitors/Volume.hs b/src/Plugins/Monitors/Volume.hs index 22b7f6c..2787a3c 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"] + ["volume", "volumebar", "volumevbar", "dB","status", "volumedstr"] data VolumeOpts = VolumeOpts @@ -34,6 +34,7 @@ data VolumeOpts = VolumeOpts , offColor :: Maybe String , highDbThresh :: Float , lowDbThresh :: Float + , volumeDynamicString :: Maybe DynamicString } defaultOpts :: VolumeOpts @@ -44,6 +45,7 @@ defaultOpts = VolumeOpts , offColor = Just "red" , highDbThresh = -5.0 , lowDbThresh = -30.0 + , volumeDynamicString = Nothing } options :: [OptDescr (VolumeOpts -> VolumeOpts)] @@ -54,6 +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 }) "") "" ] parseOpts :: [String] -> IO VolumeOpts @@ -80,6 +84,10 @@ 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 + switchHelper :: VolumeOpts -> (VolumeOpts -> Maybe String) -> (VolumeOpts -> String) @@ -126,7 +134,8 @@ runVolume mixerName controlName argv = do v <- liftMonitor $ liftM3 formatVolVBar lo hi val d <- getFormatDB opts db s <- getFormatSwitch opts sw - parseTemplate [p, b, v, d, s] + dstr <- liftMonitor $ liftM3 (formatVolDStr $ volumeDynamicString opts) lo hi val + parseTemplate [p, b, v, d, s, dstr] where |