wifi: properly handle non-existant interface
The "No such device" message was printed to stderr, find had no result and all the useless matching was done on completely empty output.
This commit is contained in:
parent
9eef646d33
commit
4fa87fadff
13
wifi.lua
13
wifi.lua
|
@ -20,11 +20,6 @@ module("vicious.wifi")
|
||||||
|
|
||||||
-- {{{ Wireless widget type
|
-- {{{ Wireless widget type
|
||||||
local function worker(format, iface)
|
local function worker(format, iface)
|
||||||
-- Get data from iwconfig (where available)
|
|
||||||
local f = io.popen("iwconfig " .. iface)
|
|
||||||
local iw = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
-- Default values
|
-- Default values
|
||||||
local winfo = {
|
local winfo = {
|
||||||
["{ssid}"] = "N/A",
|
["{ssid}"] = "N/A",
|
||||||
|
@ -35,8 +30,12 @@ local function worker(format, iface)
|
||||||
["{sign}"] = 0
|
["{sign}"] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Check if iwconfig wasn't found, can't be executed or the
|
-- Get data from iwconfig where available
|
||||||
-- interface is not a wireless one
|
local f = io.popen("iwconfig " .. iface .. " 2>&1")
|
||||||
|
local iw = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- iwconfig wasn't found, isn't executable, or non-wireless interface
|
||||||
if iw == nil or string.find(iw, "No such device") then
|
if iw == nil or string.find(iw, "No such device") then
|
||||||
return winfo
|
return winfo
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue