aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-05 00:24:43 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-05 00:24:43 +0100
commit0ab8311b02d54e22b80ced1bc1d0dde26490ba32 (patch)
tree72dbf0fc66af53edfa83fa0f11c3a54681567eb0
parent4fa87fadff5ecf0f145f72ad91599faadcb14b1a (diff)
downloadvicious-legacy-0ab8311b02d54e22b80ced1bc1d0dde26490ba32.tar.xz
wifi: properly handle iwconfig PATH differences
Most distributions keep it in /sbin, some in /usr/sbin, and somewhere it is, in other places it is not, in the user's $PATH. Now a simple discovery is done to handle this.
-rw-r--r--wifi.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/wifi.lua b/wifi.lua
index c2b2034..fc3d52e 100644
--- a/wifi.lua
+++ b/wifi.lua
@@ -5,8 +5,11 @@
-- {{{ Grab environment
local tonumber = tonumber
-local io = { popen = io.popen }
local setmetatable = setmetatable
+local io = {
+ open = io.open,
+ popen = io.popen
+}
local string = {
find = string.find,
match = string.match
@@ -31,7 +34,14 @@ local function worker(format, iface)
}
-- Get data from iwconfig where available
- local f = io.popen("iwconfig " .. iface .. " 2>&1")
+ local iwconfig = "/sbin/iwconfig"
+ local f = io.open(iwconfig, "rb")
+ if not f then
+ iwconfig = "/usr/sbin/iwconfig"
+ else
+ f:close()
+ end
+ local f = io.popen(iwconfig .." ".. iface .. " 2>&1")
local iw = f:read("*all")
f:close()