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.
This commit is contained in:
parent
4fa87fadff
commit
0ab8311b02
14
wifi.lua
14
wifi.lua
|
@ -5,8 +5,11 @@
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local io = { popen = io.popen }
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
local io = {
|
||||||
|
open = io.open,
|
||||||
|
popen = io.popen
|
||||||
|
}
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match
|
match = string.match
|
||||||
|
@ -31,7 +34,14 @@ local function worker(format, iface)
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get data from iwconfig where available
|
-- 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")
|
local iw = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue