You are not logged in.

#1 2013-07-02 12:11:30

rzrscm
Member
Registered: 2012-11-17
Posts: 95

Quick question about Awesome Vicious text widgets...

Is there a way to make it so the displayed numbers have a 0 before them when they're single digits (0-9)?

-- CPU Usage
cpuwidget = wibox.widget.textbox()
vicious.register(cpuwidget, vicious.widgets.cpu, "CPU $1% | ")

-- RAM Usage
memwidget = wibox.widget.textbox()
vicious.register(memwidget, vicious.widgets.mem, "RAM $1% |", 13)

Offline

#2 2013-07-03 12:35:39

JoshuaBranson
Member
Registered: 2012-12-19
Posts: 4

Re: Quick question about Awesome Vicious text widgets...

Change your vicious.register line to this:

vicious.register(cpuwidget, vicious.widgets.cpu, "CPU 0$1% | ")
vicious.register(memwidget, vicious.widgets.mem, "RAM 0$1% |", 13)

Also if you haven't read these web pages, you might want to give them a quick read.

http://awesome.naquadah.org/wiki/Vicious
http://git.sysphere.org/vicious/tree/README

Offline

#3 2013-07-06 18:08:43

cmtptr
Member
Registered: 2008-09-01
Posts: 135

Re: Quick question about Awesome Vicious text widgets...

JoshuaBranson wrote:

Change your vicious.register line to this:

vicious.register(cpuwidget, vicious.widgets.cpu, "CPU 0$1% | ")
vicious.register(memwidget, vicious.widgets.mem, "RAM 0$1% |", 13)

Also if you haven't read these web pages, you might want to give them a quick read.

http://awesome.naquadah.org/wiki/Vicious
http://git.sysphere.org/vicious/tree/README

I don't use vicious, but I'm pretty sure what you suggested will just prefix the value with a literal zero regardless of its width, which is not what the rzrscm was asking for.  He wants his output to be zero-padded to a fixed width of two digits.

rzrscm, from the README that JoshuaBranson linked I think this should do it:

vicous.register(cpuwidget, vicious.widgets.cpu, function (widget, args)
        return ("CPU %02d%% |"):format(args[1])
end)

Last edited by cmtptr (2013-07-06 18:09:30)

Offline

Board footer

Powered by FluxBB