-- network status and usage widget type for FreeBSD -- Copyright (C) 2017,2019 mutlusun -- Copyright (C) 2019 Nguyễn Gia Phong -- -- This file is part of Vicious. -- -- Vicious is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as -- published by the Free Software Foundation, either version 2 of the -- License, or (at your option) any later version. -- -- Vicious is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Vicious. If not, see . -- {{{ Grab environment local tonumber = tonumber local os = { time = os.time } local string = { match = string.match, gmatch = string.gmatch } local helpers = require("vicious.helpers") local spawn = require("vicious.spawn") -- }}} -- 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 parse(stdout, stderr, exitreason, exitcode) local args = {} local buffer = nil local now = os.time() for line in string.gmatch(stdout, "[^\n]+") do if not (line:find("