You are not logged in.
Hi guys,
I'm currently configuring awesome's vicious widgets. Which bother me is that the text widgets jumping around when the number increase/decrease few digits. From cmtptr's answer from this thread, I finally found the way to get CPU and mem widgets stand still as each of them only require one argument:
-- Create a CPU usage widget
cpuwidget = wibox.widget.textbox()
vicious.register(
cpuwidget,
vicious.widgets.cpu,
function (widget, args)
return (" CPU %3d%% |"):format(args[1])
end,
1)What I'm stucked with right now is the vicious.widget.net - it requires this kind of arg: ${wlp2s2 down_kb}. Currently I'm having this in my rc.lua:
-- Create a network usage widget
netwidget = wibox.widget.textbox()
vicious.register(
netwidget,
vicious.widgets.net,
" DOWN ${wlp2s2 down_kb}kB | UP ${wlp2s2 up_kb}kB ",
1)Is there any way I can format this widget to have a certain width so that it doesn't jump around? I don't know any Lua but obviously this doesn't work:
function (widget, args)
return (" DOWN %4skB |"):format(args[{wlp2s2 down_kb}])
endSorry for my bad English. Thanks in advance.
Last edited by cnx (2016-01-15 03:28:30)
Offline
There is a distinct difference between the two.
One returns a variable to work with, the other expects a variable to work with.
AFAIK: To achieve this you would need to change the vicious.netwidget itself to return its output in the proper format.
But then again, i dont know lua well enough.
As a semi-workaround, you can place that at the inner bindings or at the border of central aligned widgets.
Example: The one most right of the upper left widget group.
hth
Offline
Thanks for quick respond. I've already done that, but I want to have a more prefect solution.
Offline
From vicious readme:
"When it comes to padding it is also useful to mention how a widget can
be configured to have a fixed width. You can set a fixed width on your
textbox widgets by changing their .width field (by default width is
automatically adapted to text width).
Example
uptimewidget = wibox.widget.textbox()
uptimewidget:set_align("right")
vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
uptimewidget = wibox.layout.constraint(uptimewidget, "exact", 50, nil) - forces a fixed width of 50px to the uptime widget, and aligns its
text to the right "
Also in
args[{wlp2s2 down_kb}]
args is array, so index should be integer
Hope that helps.
Offline
Thanks. After reading that part of the README, I finally found the solution:
-- Create a network usage widget
netwidget = wibox.widget.textbox()
vicious.register(
netwidget,
vicious.widgets.net,
function (widget, args)
return (" DOWN %6skB | UP %6skB "):format(args["{wlp2s2 down_kb}"],
args["{wlp2s2 up_kb}"])
end,
1)Last edited by cnx (2016-01-15 03:26:48)
Offline