summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/Wireless.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugins/Monitors/Wireless.hs')
-rw-r--r--src/Plugins/Monitors/Wireless.hs34
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]