aboutsummaryrefslogtreecommitdiff
path: root/wifi.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-12-27 20:32:25 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-12-27 20:32:25 +0100
commitcedf1711bfc303df8e9ece67e5d313dba188b258 (patch)
tree5bfc4cfc99cf15fdf6fb882b4a3a1578c1348a03 /wifi.lua
parentfba4db6d3764f95b7dbf9bb3794c4fe1587206c4 (diff)
downloadvicious-legacy-cedf1711bfc303df8e9ece67e5d313dba188b258.tar.xz
wifi: return numbers without notations
Diffstat (limited to 'wifi.lua')
-rw-r--r--wifi.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/wifi.lua b/wifi.lua
index 7e975ed..ccfced9 100644
--- a/wifi.lua
+++ b/wifi.lua
@@ -30,9 +30,9 @@ local function worker(format, iface)
["{ssid}"] = "N/A",
["{mode}"] = "N/A",
["{chan}"] = "N/A",
- ["{rate}"] = "N/A",
+ ["{rate}"] = 0,
["{link}"] = 0,
- ["{sign}"] = "N/A"
+ ["{sign}"] = 0
}
-- Check if iwconfig wasn't found, can't be executed or the
@@ -49,14 +49,12 @@ local function worker(format, iface)
string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"]
winfo["{chan}"] = -- Channels are plain digits
tonumber(string.match(iw, "Channel[=:]([%d]+)") or winfo["{chan}"])
- winfo["{rate}"] = -- Bitrate can start with a space and we want to display Mb/s
- string.match(iw, "Bit Rate[=:]([%s]?[%d%.]*[%s][%/%a]+)") or winfo["{rate}"]
--- winfo["{link}"] = -- Link quality can contain a slash: 32/100
--- string.match(iw, "Link Quality[=:]([%d]+[%/%d]*)") or winfo["{link}"]
- winfo["{link}"] = -- * match only the first number, also suitable for a progressbar
+ winfo["{rate}"] = -- Bitrate can start with a space, we don't want to display Mb/s
+ tonumber(string.match(iw, "Bit Rate[=:]([%s]?[%d%.]*)") or winfo["{rate}"])
+ winfo["{link}"] = -- Link quality can contain a slash (32/70), match only the first number
tonumber(string.match(iw, "Link Quality[=:]([%d]+)") or winfo["{link}"])
- winfo["{sign}"] = -- Signal level can be a negative value, also display decibel notation
- string.match(iw, "Signal level[=:]([%-%d]+[%s][%a]*)") or winfo["{sign}"]
+ winfo["{sign}"] = -- Signal level can be a negative value, don't display decibel notation
+ tonumber(string.match(iw, "Signal level[=:]([%-]?[%d]+)") or winfo["{sign}"])
return winfo
end