From 44452e609f00127bb34d83f5643417be966a9352 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 1 Nov 2015 01:47:31 +0100 Subject: [PATCH] net: provide list of available nets This makes it easier to loop over them and/or handle them separately. --- widgets/net_linux.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widgets/net_linux.lua b/widgets/net_linux.lua index 6636f62..b9bce3d 100644 --- a/widgets/net_linux.lua +++ b/widgets/net_linux.lua @@ -28,13 +28,14 @@ local unit = { ["b"] = 1, ["kb"] = 1024, -- {{{ Net widget type local function worker(format) - local args = {} + local args = { nets = {} } -- Get NET stats for line in io.lines("/proc/net/dev") do -- Match wmaster0 as well as rt0 (multiple leading spaces) local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):") if name ~= nil then + table.insert(args["nets"], name) -- Received bytes, first value after the name local recv = tonumber(string.match(line, ":[%s]*([%d]+)")) -- Transmited bytes, 7 fields from end of the line