diff --git a/widgets/net_freebsd.lua b/widgets/net_freebsd.lua index f78b016..2aa1180 100644 --- a/widgets/net_freebsd.lua +++ b/widgets/net_freebsd.lua @@ -1,10 +1,12 @@ -- {{{ Grab environment local tonumber = tonumber local os = { time = os.time } -local setmetatable = setmetatable local helpers = require("vicious.helpers") -local io = { popen = io.popen } -local string = { match = string.match } +local spawn = require("vicious.spawn") +local string = { + match = string.match, + gmatch = string.gmatch +} -- }}} @@ -21,15 +23,13 @@ local unit = { ["b"] = 1, ["kb"] = 1024, } -- {{{ Net widget type -local function worker(format, warg) - if not warg then return end +local function parse(stdout, stderr, exitreason, exitcode) local args = {} local buffer = nil - local f = io.popen("netstat -n -b -I " .. helpers.shellquote(warg)) local now = os.time() - for line in f:lines() do + for line in string.gmatch(stdout, "[^\n]+") do if not (line:find("