summaryrefslogtreecommitdiffhomepage
path: root/src/lib/Xmobar/Plugins/Monitors/Wireless.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2018-11-25 15:10:29 +0000
committerjao <jao@gnu.org>2018-11-25 15:10:29 +0000
commit77df1ac30fa7af5948f7ff64f5fee9aed64552b3 (patch)
tree647a4eb67ff1c293a5c530538ee88fc0093b577a /src/lib/Xmobar/Plugins/Monitors/Wireless.hs
parente0d6da82de8d0d1cef98896164c6016b84e47068 (diff)
downloadxmobar-77df1ac30fa7af5948f7ff64f5fee9aed64552b3.tar.gz
xmobar-77df1ac30fa7af5948f7ff64f5fee9aed64552b3.tar.bz2
Back to app/src, since it seems they're the default convention for stack
Diffstat (limited to 'src/lib/Xmobar/Plugins/Monitors/Wireless.hs')
-rw-r--r--src/lib/Xmobar/Plugins/Monitors/Wireless.hs70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/lib/Xmobar/Plugins/Monitors/Wireless.hs b/src/lib/Xmobar/Plugins/Monitors/Wireless.hs
deleted file mode 100644
index 545f6bc..0000000
--- a/src/lib/Xmobar/Plugins/Monitors/Wireless.hs
+++ /dev/null
@@ -1,70 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Plugins.Monitors.Wireless
--- Copyright : (c) Jose Antonio Ortega Ruiz
--- License : BSD-style (see LICENSE)
---
--- Maintainer : Jose Antonio Ortega Ruiz
--- Stability : unstable
--- Portability : unportable
---
--- A monitor reporting ESSID and link quality for wireless interfaces
---
------------------------------------------------------------------------------
-
-module Xmobar.Plugins.Monitors.Wireless (wirelessConfig, runWireless) where
-
-import System.Console.GetOpt
-
-import Xmobar.Plugins.Monitors.Common
-import Network.IWlib
-
-newtype 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", "qualityvbar", "qualityipat"]
-
-runWireless :: String -> [String] -> Monitor String
-runWireless iface args = do
- opts <- io $ parseOpts args
- iface' <- if "" == iface then io findInterface else return iface
- wi <- io $ getWirelessInfo iface'
- na <- getConfigValue naString
- let essid = wiEssid wi
- qlty = fromIntegral $ wiQuality wi
- e = if essid == "" then na else essid
- ep <- showWithPadding e
- q <- if qlty >= 0
- then showPercentWithColors (qlty / 100)
- else showWithPadding ""
- qb <- showPercentBar qlty (qlty / 100)
- qvb <- showVerticalBar qlty (qlty / 100)
- qipat <- showIconPattern (qualityIconPattern opts) (qlty / 100)
- parseTemplate [ep, q, qb, qvb, qipat]
-
-findInterface :: IO String
-findInterface = do
- c <- readFile "/proc/net/wireless"
- let nds = lines c
- return $ if length nds > 2 then takeWhile (/= 'c') (nds!!2) else []