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/Wireless.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/Wireless.hs')
-rw-r--r-- | src/Plugins/Monitors/Wireless.hs | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/Wireless.hs b/src/Plugins/Monitors/Wireless.hs index c6e6b44..c87bec6 100644 --- a/src/Plugins/Monitors/Wireless.hs +++ b/src/Plugins/Monitors/Wireless.hs @@ -14,15 +14,39 @@ module Plugins.Monitors.Wireless (wirelessConfig, runWireless) where +import System.Console.GetOpt + import Plugins.Monitors.Common import IWlib +data WirelessOpts = WirelessOpts + { qualityDynamicString :: Maybe DynamicString + } + +defaultOpts :: WirelessOpts +defaultOpts = WirelessOpts + { qualityDynamicString = Nothing + } + +options :: [OptDescr (WirelessOpts -> WirelessOpts)] +options = + [ Option "" ["quality-dynamic-string"] (ReqArg (\d opts -> + opts { qualityDynamicString = Just $ parseDynamicString d }) "") "" + ] + +parseOpts :: [String] -> IO WirelessOpts +parseOpts argv = + case getOpt Permute options argv of + (o, _, []) -> return $ foldr id defaultOpts o + (_, _, errs) -> ioError . userError $ concat errs + wirelessConfig :: IO MConfig wirelessConfig = - mkMConfig "<essid> <quality>" ["essid", "quality", "qualitybar", "qualityvbar"] + mkMConfig "<essid> <quality>" ["essid", "quality", "qualitybar", "qualityvbar", "qualitydstr"] -runWireless :: [String] -> Monitor String -runWireless (iface:_) = do +runWireless :: String -> [String] -> Monitor String +runWireless iface args = do + opts <- io $ parseOpts args wi <- io $ getWirelessInfo iface na <- getConfigValue naString let essid = wiEssid wi @@ -34,5 +58,5 @@ runWireless (iface:_) = do else showWithPadding "" qb <- showPercentBar qlty (qlty / 100) qvb <- showVerticalBar qlty (qlty / 100) - parseTemplate [ep, q, qb, qvb] -runWireless _ = getConfigValue naString + qdstr <- showDynamicString (qualityDynamicString opts) (qlty / 100) + parseTemplate [ep, q, qb, qvb, qdstr] |