aboutsummaryrefslogtreecommitdiff
path: root/contrib/netcfg.lua
blob: fc22e8d251cd8f87bc4c50af2879c6927e51c607 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---------------------------------------------------
-- Licensed under the GNU General Public License v2
--  * (c) 2010, Radu A. <admiral0@tuxfamily.org>
---------------------------------------------------

-- {{{ Grab environment
local io = { popen = io.popen }
local setmetatable = setmetatable
local table = { insert = table.insert }
-- }}}


-- Netcfg: provides active netcfg network profiles
module("vicious.contrib.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 })