summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Wireless.hs
blob: fe81ab86291d6af1f2888db349c425817a235225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-----------------------------------------------------------------------------
-- |
-- 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 Plugins.Monitors.Wireless (wirelessConfig, runWireless)  where

import Plugins.Monitors.Common
import IWlib

wirelessConfig :: IO MConfig
wirelessConfig = mkMConfig "<essid> <quality>" ["essid", "quality"]

runWireless :: [String] -> Monitor String
runWireless (iface:_) = do
  wi <- io $ getWirelessInfo iface
  let essid = wiEssid wi
      quality = wiQuality wi
      e = if essid == "" then "N/A" else essid
  q <- if quality >= 0
       then showWithColors show quality
       else showWithColors' "" (0 :: Int)
  parseTemplate [e, q]
runWireless _ = return ""