diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-06 21:44:23 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-06 21:44:23 +0100 |
commit | aa02126c47268200a5cdc860f3c1b9458fdf94b3 (patch) | |
tree | 41fc622d9c10d8093e5908c22224c2ee8a577a3e | |
parent | ff80f8675359f861d6b807e49f70a8227b6ab0b0 (diff) | |
download | xmobar-aa02126c47268200a5cdc860f3c1b9458fdf94b3.tar.gz xmobar-aa02126c47268200a5cdc860f3c1b9458fdf94b3.tar.bz2 |
IWlib: avoid reporting negative quality values
-rw-r--r-- | IWlib.hsc | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -56,7 +56,7 @@ getWirelessInfo iface = str <- c_iw_stats i istr stats rng 1 rgr <- c_iw_range i istr rng c_iw_close i - if (bcr < 0) then return nullInfo else + if (bcr < 0) then return WirelessInfo { wiEssid = "", wiQuality = 0 } else do hase <- (#peek struct wireless_config, has_essid) wc :: IO CInt eon <- (#peek struct wireless_config, essid_on) wc :: IO CInt essid <- if hase /= 0 && eon /= 0 then @@ -68,9 +68,8 @@ getWirelessInfo iface = mv <- xqual $ (#ptr struct iw_range, max_qual) rng let mxv = if mv /= 0 then fromIntegral mv else 1 return $ fromIntegral qualv / mxv - else return (-1) + else return 0 let qv = round (100 * (q :: Double)) return $ WirelessInfo { wiEssid = essid, wiQuality = min 100 qv } - where nullInfo = WirelessInfo { wiEssid = "", wiQuality = -1 } - xqual p = let qp = (#ptr struct iw_param, value) p in + where xqual p = let qp = (#ptr struct iw_param, value) p in (#peek struct iw_quality, qual) qp :: IO CChar |