diff options
author | Jose A Ortega Ruiz <jao@gnu.org> | 2010-02-21 21:38:09 +0100 |
---|---|---|
committer | Jose A Ortega Ruiz <jao@gnu.org> | 2010-02-21 21:38:09 +0100 |
commit | d56e2da928343b9cadb8e034036926e089ad861e (patch) | |
tree | 9e316ea2523d97f8f208a580de9ddafc35412052 /Plugins | |
parent | 7f9eb02f5c420d8f9e425310d3982145649dbba1 (diff) | |
download | xmobar-d56e2da928343b9cadb8e034036926e089ad861e.tar.gz xmobar-d56e2da928343b9cadb8e034036926e089ad861e.tar.bz2 |
New Wireless monitor
Ignore-this: b1b66ffa9077f8d41a5c0e962ee0bff3
darcs-hash:20100221203809-748be-71bc1951a2eb8164b0043725bcb707f42e530ded.gz
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/Monitors.hs | 12 | ||||
-rw-r--r-- | Plugins/Monitors/Wireless.hs | 31 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Plugins/Monitors.hs b/Plugins/Monitors.hs index cba7332..2aff132 100644 --- a/Plugins/Monitors.hs +++ b/Plugins/Monitors.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ----------------------------------------------------------------------------- -- | -- Module : Xmobar.Plugins.Monitors @@ -29,6 +31,9 @@ import Plugins.Monitors.CpuFreq import Plugins.Monitors.CoreTemp import Plugins.Monitors.Disk import Plugins.Monitors.Top +#ifdef IWLIB +import Plugins.Monitors.Wireless +#endif data Monitors = Weather Station Args Rate | Network Interface Args Rate @@ -45,6 +50,9 @@ data Monitors = Weather Station Args Rate | CoreTemp Args Rate | TopCpu Args Rate | TopMem Args Rate +#ifdef IWLIB + | Wireless Interface Args Rate +#endif deriving (Show,Read,Eq) type Args = [String] @@ -72,6 +80,10 @@ instance Exec Monitors where alias (CoreTemp _ _) = "coretemp" alias (DiskU _ _ _) = "disku" alias (DiskIO _ _ _) = "diskio" +#ifdef IWLIB + alias (Wireless i _ _) = i ++ "wi" + start (Wireless i a r) = runM (a ++ [i]) wirelessConfig runWireless r +#endif start (Weather s a r) = runM (a ++ [s]) weatherConfig runWeather r start (Network i a r) = runM (a ++ [i]) netConfig runNet r start (Thermal z a r) = runM (a ++ [z]) thermalConfig runThermal r diff --git a/Plugins/Monitors/Wireless.hs b/Plugins/Monitors/Wireless.hs new file mode 100644 index 0000000..167a48f --- /dev/null +++ b/Plugins/Monitors/Wireless.hs @@ -0,0 +1,31 @@ +----------------------------------------------------------------------------- +-- | +-- 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 return "N/A" + parseTemplate [e, q] +runWireless _ = return ""
\ No newline at end of file |