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.hs42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/Plugins/Monitors/Wireless.hs b/src/Plugins/Monitors/Wireless.hs
index 8d32c99..b1e3c7e 100644
--- a/src/Plugins/Monitors/Wireless.hs
+++ b/src/Plugins/Monitors/Wireless.hs
@@ -14,21 +14,49 @@
module Plugins.Monitors.Wireless (wirelessConfig, runWireless) where
+import System.Console.GetOpt
+
import Plugins.Monitors.Common
import IWlib
+data WirelessOpts = WirelessOpts
+ { qualityIconPattern :: Maybe IconPattern
+ }
+
+defaultOpts :: WirelessOpts
+defaultOpts = WirelessOpts
+ { qualityIconPattern = Nothing
+ }
+
+options :: [OptDescr (WirelessOpts -> WirelessOpts)]
+options =
+ [ Option "" ["quality-icon-pattern"] (ReqArg (\d opts ->
+ opts { qualityIconPattern = Just $ parseIconPattern 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"]
+ mkMConfig "<essid> <quality>" ["essid", "quality", "qualitybar", "qualityvbar", "qualityipat"]
-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
qlty = fromIntegral $ wiQuality wi
- e = if essid == "" then "N/A" else essid
+ e = if essid == "" then na else essid
ep <- showWithPadding e
- q <- if qlty >= 0 then showPercentWithColors (qlty/100) else showWithPadding ""
+ q <- if qlty >= 0
+ then showPercentWithColors (qlty / 100)
+ else showWithPadding ""
qb <- showPercentBar qlty (qlty / 100)
- parseTemplate [ep, q, qb]
-runWireless _ = return ""
+ qvb <- showVerticalBar qlty (qlty / 100)
+ qipat <- showIconPattern (qualityIconPattern opts) (qlty / 100)
+ parseTemplate [ep, q, qb, qvb, qipat]