From cedf1711bfc303df8e9ece67e5d313dba188b258 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 27 Dec 2009 20:32:25 +0100 Subject: wifi: return numbers without notations --- wifi.lua | 16 +++++++--------- 1 file 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 -- cgit v1.2.3