widgets: minor cleanup before a tag in cpuinf, fs, mbox...

This commit is contained in:
Adrian C. (anrxc) 2010-03-15 17:55:25 +01:00
parent 4fc6dffe94
commit 0299c15dc0
5 changed files with 7 additions and 11 deletions

View File

@ -18,9 +18,8 @@ module("vicious.widgets.cpuinf")
-- {{{ CPU Information widget type
local function worker(format)
local id = nil
local cpu_info = {}
-- Get CPU info
local cpu_info = {} -- Get CPU info
for line in io.lines("/proc/cpuinfo") do
for k, v in string.gmatch(line, "([%a%s]+)[%s]+:[%s]([%d]+).-$") do
if k == "processor" then

View File

@ -25,9 +25,8 @@ local function worker(format, warg)
-- Fallback to listing local filesystems
if warg then warg = "" else warg = "-l" end
-- Get (non-localized)data from df
local fs_info = {} -- Get data from df
local f = io.popen("LC_ALL=C df -kP " .. warg)
local fs_info = {}
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
local s = string.match(line, "^.-[%s]([%d]+)")

View File

@ -20,9 +20,8 @@ local function worker(format, warg)
-- Fallback to default hddtemp warg
if warg == nil then warg = 7634 end
-- Get info from the hddtemp daemon
local hdd_temp = {} -- Get info from the hddtemp daemon
local f = io.popen("curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:"..warg)
local hdd_temp = {}
for line in f:lines() do
for d, t in string.gmatch(line, "|([%/%a%d]+)|.-|([%d]+)|[CF]+|") do

View File

@ -20,6 +20,9 @@ module("vicious.widgets.mbox")
local function worker(format, warg)
if not warg then return end
-- Default value
local subject = "N/A"
-- mbox could be huge, get a 30kb chunk from EOF
if type(warg) ~= "table" then mbox = warg end
-- * attachment could be much bigger than 30kb
@ -28,9 +31,6 @@ local function worker(format, warg)
local txt = f:read("*all")
f:close()
-- Default value
local subject = "N/A"
-- Find all Subject lines
for i in string.gfind(txt, "Subject: ([^\n]*)") do
subject = i

View File

@ -26,8 +26,7 @@ local function worker(format)
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
-- Get load averages
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
string.match(proc.loadavg, "([%d]*%.[%d]*)%s([%d]*%.[%d]*)%s([%d]*%.[%d]*)")
return {up_d, up_h, up_m, l1, l5, l15}