| 1 | -- contrib/netcfg.lua |
| 2 | -- Copyright (C) 2010 Radu A. <[email protected]> |
| 3 | -- Copyright (C) 2010 Adrian C. (anrxc) <[email protected]> |
| 4 | -- Copyright (C) 2012 Arvydas Sidorenko <[email protected]> |
| 5 | -- |
| 6 | -- This file is part of Vicious. |
| 7 | -- |
| 8 | -- Vicious is free software: you can redistribute it and/or modify |
| 9 | -- it under the terms of the GNU General Public License as |
| 10 | -- published by the Free Software Foundation, either version 2 of the |
| 11 | -- License, or (at your option) any later version. |
| 12 | -- |
| 13 | -- Vicious is distributed in the hope that it will be useful, |
| 14 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | -- GNU General Public License for more details. |
| 17 | -- |
| 18 | -- You should have received a copy of the GNU General Public License |
| 19 | -- along with Vicious. If not, see <https://www.gnu.org/licenses/>. |
| 20 | |
| 21 | -- {{{ Grab environment |
| 22 | local io = { popen = io.popen } |
| 23 | local setmetatable = setmetatable |
| 24 | local table = { insert = table.insert } |
| 25 | -- }}} |
| 26 | |
| 27 | |
| 28 | -- Netcfg: provides active netcfg network profiles |
| 29 | -- vicious.contrib.netcfg |
| 30 | local netcfg = {} |
| 31 | |
| 32 | |
| 33 | -- {{{ Netcfg widget type |
| 34 | local function worker(format) |
| 35 | -- Initialize counters |
| 36 | local profiles = {} |
| 37 | |
| 38 | local f = io.popen("ls -1 /var/run/network/profiles") |
| 39 | for line in f:lines() do |
| 40 | if line ~= nil then |
| 41 | table.insert(profiles, line) |
| 42 | end |
| 43 | end |
| 44 | f:close() |
| 45 | |
| 46 | return profiles |
| 47 | end |
| 48 | -- }}} |
| 49 | |
| 50 | return setmetatable(netcfg, { __call = function(_, ...) return worker(...) end }) |