aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-05 00:10:25 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-05 00:10:25 +0100
commit4fa87fadff5ecf0f145f72ad91599faadcb14b1a (patch)
tree37dfe51de77608ff736178b051fa41a71bc3b647
parent9eef646d33ff0c8eccfbf39c4c35d0e4bb14c233 (diff)
downloadvicious-legacy-4fa87fadff5ecf0f145f72ad91599faadcb14b1a.tar.xz
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.
-rw-r--r--wifi.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/wifi.lua b/wifi.lua
index 8a91c1e..c2b2034 100644
--- a/wifi.lua
+++ b/wifi.lua
@@ -20,11 +20,6 @@ module("vicious.wifi")
-- {{{ Wireless widget type
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
local winfo = {
["{ssid}"] = "N/A",
@@ -35,8 +30,12 @@ local function worker(format, iface)
["{sign}"] = 0
}
- -- Check if iwconfig wasn't found, can't be executed or the
- -- interface is not a wireless one
+ -- Get data from iwconfig where available
+ 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
return winfo
end