summaryrefslogtreecommitdiffhomepage
path: root/IWlib.hsc
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-02-22 15:42:26 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-02-22 15:42:26 +0100
commit32dc866c396c262d3781e03bdfd1acd2b4a151ee (patch)
treebc6edd435e0e93d94c76c5849b50e56575bb6bb7 /IWlib.hsc
parentfd7de94c92b5d094bd244a06f8b330237ed7e99d (diff)
downloadxmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.gz
xmobar-32dc866c396c262d3781e03bdfd1acd2b4a151ee.tar.bz2
Wireless monitor: better boundary checks
Ignore-this: cfb69e10b2eaff6924a2df32b1e51bf0 darcs-hash:20100222144226-748be-f28cbe827c89238074448b23da7ba606f930ceb9.gz
Diffstat (limited to 'IWlib.hsc')
-rw-r--r--IWlib.hsc5
1 files changed, 3 insertions, 2 deletions
diff --git a/IWlib.hsc b/IWlib.hsc
index afd6bf0..f0bc655 100644
--- a/IWlib.hsc
+++ b/IWlib.hsc
@@ -69,7 +69,8 @@ getWirelessInfo iface =
qualv <- (#peek struct iw_param, value) qual :: IO CInt
let qualm = (#ptr struct iw_range, max_qual) rng
mv <- (#peek struct iw_param, value) qualm :: IO CInt
- return $ fromIntegral qualv / fromIntegral (max 1 mv)
+ let mxv = if mv > 0 then fromIntegral mv else 1
+ return $ fromIntegral qualv / mxv
else return (-1)
let qv = round (100 * (q :: Double))
- return $ WirelessInfo { wiEssid = essid, wiQuality = qv }
+ return $ WirelessInfo { wiEssid = essid, wiQuality = min 100 qv }