diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-04-02 01:08:12 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-04-02 01:08:12 +0200 |
commit | 448275a3865d1db82a6fc37d60548da8b865e5e0 (patch) | |
tree | ed0b9134b26d2002ec289210fb0915f41b26d59f /widgets/raid.lua | |
parent | a9347ec0d033aa08d77fcc75c35d88514f9e84f5 (diff) | |
download | vicious-legacy-448275a3865d1db82a6fc37d60548da8b865e5e0.tar.xz |
widgets: reuse existing datasets where appropriate
Gmail, mbox, raid, weather and wifi could return the old value in case
there isn't new data, no need for N/A to be so common on our wibox.
Diffstat (limited to 'widgets/raid.lua')
-rw-r--r-- | widgets/raid.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/widgets/raid.lua b/widgets/raid.lua index eaf7825..3f9ef43 100644 --- a/widgets/raid.lua +++ b/widgets/raid.lua @@ -19,20 +19,23 @@ local string = { module("vicious.widgets.raid") +-- Initialize function tables +local mddev = {} + -- {{{ RAID widget type local function worker(format, warg) if not warg then return end - - local found = false - local mddev = {} - mddev[warg] = { - ["active"] = 0, - ["assigned"] = 0 - } + if not mddev[warg] then + mddev[warg] = { + ["found"] = false, + ["active"] = 0, + ["assigned"] = 0 + } + end -- Linux manual page: md(4) for line in io.lines("/proc/mdstat") do - if found then + if mddev[warg]["found"] then local updev = string.match(line, "%[[_U]+%]") for i in string.gmatch(updev, "U") do @@ -41,7 +44,7 @@ local function worker(format, warg) break elseif string.sub(line, 1, string.len(warg)) == warg then - found = true + mddev[warg]["found"] = true for i in string.gmatch(line, "%[%d%]") do mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1 |