From 5a1eb907b74e6efb458df156bb6cdec574570edf Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sun, 30 May 2010 17:47:48 +0200 Subject: [PATCH] contrib: imported netcfg widget from Radu Widget type by Radu provides active netcfg profiles in a table. In contrib until we see what can be done with this, who wants to use it and if data should be provided in other formats. We can't be certain of the number of active profiles so a format string like $1|$2|$3 will vary between sessions. --- extra/netcfg.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 extra/netcfg.lua diff --git a/extra/netcfg.lua b/extra/netcfg.lua new file mode 100644 index 0000000..6d859fe --- /dev/null +++ b/extra/netcfg.lua @@ -0,0 +1,34 @@ +--------------------------------------------------- +-- Licensed under the GNU General Public License v2 +-- * (c) 2010, Radu A. +--------------------------------------------------- + +-- {{{ Grab environment +local io = { popen = io.popen } +local setmetatable = setmetatable +local table = { insert = table.insert } +-- }}} + + +-- Netcfg: provides active netcfg network profiles +module("vicious.widgets.netcfg") + + +-- {{{ Netcfg widget type +local function worker(format) + -- Initialize counters + local profiles = {} + + local f = io.popen("ls -1 /var/run/network/profiles") + for line in f:lines() do + if line ~= nil then + table.insert(profiles, line) + end + end + f:close() + + return profiles +end +-- }}} + +setmetatable(_M, { __call = function(_, ...) return worker(...) end })