2 -- Copyright (c) 2007, Bart Trojanowski <bart@jukie.net>
4 -- Simple load applet for wmii bar.
6 -- NOTE: dstat is required.
8 local wmii
= require("wmii")
9 local os
= require("os")
10 local math
= require("math")
11 local string = require("string")
13 local tonumber = tonumber
14 local tostring = tostring
19 local palette
= { "#888888",
33 local widget
= wmii
.widget
:new ("800_dstat_load")
34 wmii
.add_exec ("TERM=vt100 dstat --load --nocolor --noheaders --noupdate 1",
36 if type(line
) ~= "string" then
40 local line
= line
:gsub ("%W%W+", " ")
41 if line
:len() < 5 then
45 local tmp
= line
:match("([%d.]+)%D")
46 local current
= tonumber(tmp
)
49 if type(current
) == "number" then
50 local index
= math
.min (math
.floor(current
* (#palette
-1)) + 1, #palette
)
51 local normal
= wmii
.get_ctl("normcolors")
52 colors
= string.gsub(normal
, "^%S+", palette
[index
], 1)
55 widget
:show (line
, colors
)