net: iface scope fixed 2

This commit is contained in:
luke bonham 2014-11-15 13:38:07 +01:00 committed by copycat-killer
parent e07eee4618
commit 1d5e6f2516
1 changed files with 6 additions and 2 deletions

View File

@ -16,7 +16,8 @@ local wibox = require("wibox")
local io = { popen = io.popen }
local tostring = tostring
local string = { format = string.format,
gsub = string.gsub }
gsub = string.gsub,
match = string.match }
local setmetatable = setmetatable
@ -56,7 +57,10 @@ local function worker(args)
function update()
net_now = {}
if iface == "" then iface = net.get_device() end
if iface == "" or string.match(iface, "network off")
then
iface = net.get_device()
end
net_now.carrier = helpers.first_line('/sys/class/net/' .. iface ..
'/carrier') or "0"