From 1d5e6f2516b5b3fd8a50d7dfe9dc7cb3ddb9ff40 Mon Sep 17 00:00:00 2001 From: luke bonham Date: Sat, 15 Nov 2014 13:38:07 +0100 Subject: [PATCH 1/1] net: iface scope fixed 2 --- widgets/net.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/widgets/net.lua b/widgets/net.lua index d1179a2..2b06622 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -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" -- 2.39.5