Damien Rajon <[email protected]> writes:

> Hey,
>
> I was wondering, since wicked offers a padding functionality, why not
> use it with all widgets.
> I am talking specially about the net widget and the ${interface
> down_XX} variants ?

I faced the same problem, and ended up cheating and doing my own widget
that calls wicked.widgets.net and formats the output with string.format :)

See just below for the relevant code (which can probably be improved).


netwidget = widget({ type = 'textbox', name = 'netwidget', align = 'right' })

function extract_net_info(format)
   local values = wicked.widgets.net(format,false)

   local eth1_up = tonumber(values['{eth1 up_kb}'])
   local eth1_down = tonumber(values['{eth1 down_kb}'])

   local eth0_up   = tonumber(values['{eth0 up_kb}'])
   local eth0_down = tonumber(values['{eth0 down_kb}'])

   -- [eth0: xxx/xxx][eth1: xxx/xxx] with xxx in mono font
   local v = '<span color="#676767">[eth0</span>: <span font_desc="DejaVu Sans 
Mono 8">' .. string.format("%3d",eth0_down) .. '</span>' .. 
      '<span color="#676767">/</span><span font_desc="DejaVu Sans Mono 8">' .. 
string.format("%3d",eth0_up) ..  '</span>' .. 
     '<span color="#676767">][eth1</span>: <span font_desc="DejaVu Sans Mono 
8">' .. string.format("%3d",eth1_down) ..  '</span>' .. 
     '<span color="#676767">/</span><span font_desc="DejaVu Sans Mono 8">' .. 
string.format("%3d",eth1_up) .. '</span>' .. 
      '<span color="#676767">]</span> '
   
   return {v}
end

wicked.register(netwidget, extract_net_info,"$1", 1, nil, nil)



-- 
To unsubscribe, send mail to [email protected].

Reply via email to