8
1
I currently experimenting with DWM and Conky to create a minimal looking desktop to use for coding and things like that. I've got something nice going on, but there's something I'm having an issue with at the moment. Right now, my Conky TEXT
section is centre aligned, which looks nice, but it is also returning information about CPU usage. If the CPU usage is flickering between, say, 9 and 10 %, the overall size of the text is different, and because it's centre aligned, it moved around a bit. Colours removed for a second for clarity, here's a simple version of the line in question...
${alignc}CPU: ${cpu}%
The difference, of course, between the two of
CPU 9%
CPU 10%
is what's causing the issue. How would I go about left-padding the 9 with two zeroes, then 10 with one zero, and then 100 with no zeroes? The only thing I can see vaguely related in the documentation has to deal with decimal place padding, which isn't what I need at all.
This works great, hadn't added extra lua scripts before! I updated the function by adding a
padding
arg, also made it able to pad strings by changingnumber
tovalue
and do:string.format(string.format('%%%is', conky_parse(padding)), conky_parse(value))
– mVChr – 2017-03-08T22:10:11.163I'm afraid I'm not in a position to test it, but it looks valid to my (reasonably novice) Conky eye. And it's a cool little hack to boot ^^ – JBirch – 2010-08-20T09:28:51.117
Let me know, once you've tested it, for any issues. – cYrus – 2010-08-20T09:50:32.130