diff --git a/widgets/net_freebsd.lua b/widgets/net_freebsd.lua new file mode 100644 index 0000000..f78b016 --- /dev/null +++ b/widgets/net_freebsd.lua @@ -0,0 +1,83 @@ +-- {{{ 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 } +-- }}} + + +-- Net: provides state and usage statistics of all network interfaces +-- vicious.widgets.net +local net_freebsd = {} + + +-- Initialize function tables +local nets = {} +-- Variable definitions +local unit = { ["b"] = 1, ["kb"] = 1024, + ["mb"] = 1024^2, ["gb"] = 1024^3 +} + +-- {{{ Net widget type +local function worker(format, warg) + if not warg then return end + + 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 + if not (line:find("