Goto/offset/voffset (en)

From Conky PitStop

Jump to: navigation, search


 Language   English   Français   


So you need to do some work regarding “spacing” in conky. You did read the page entitled: Spacing I hope.

Some recommendations to consider:

1. For your conky file above TEXT lines required to pad the % outputs to two places, and use short units:

short_units yes
pad_percents 2

short_units means you’ll see M vs M/b or G vs G/b. And pad_percents insures all % output into conky is done with 2 decimal places, unless you use another program like vnstat to get output. Another nice thing about this is if you use the ${goto} command to place them, it uses the decimal point as the reference.


2. When considering spacing as a “critical” factor in your display, I can't stress enough that “mono” fonts are important.

3. One also has to consider the font and font size. For example the woodbadge font used below is “NOT” a mono font and at a size of 40 a single space between words or characters is much larger then (for example) DejaVu Sans Mono:bold:size=9, and that is just hitting the “spacebar”. So always turn off fonts (with ${font}) before you go to another line or add a space for the next command – unless you want that large space.

For example:

${font woodbadge:size=40}Name:  ${font DejaVu Sans Mono:bold:size=9}Bruce
Address: 123 Any St.${font}

would display different than:

${font woodbadge:size=40}Name:${font DejaVu Sans Mono:bold:size=9}  Bruce
Address: 123 Any St.${font}

because of the change in font and size. Check where the “space” is between the
   Name: ${font DejaVu Sans Mono:bold:size=9}Bruce
   Name:${font DejaVu Sans Mono:bold:size=9} Bruce
That’s the only difference between those two lines. Spacing is important!


OK, Lets start

OK, so what do ${goto}, ${offset} and ${voffset} do. Basically they move the output from commands to another place on the display.

${goto xx} – goto normally uses a positive number to move text xx number of pixels to the right of zero. That “of zero” is important, it is the extreme left side of your conky output displayed on your screen. Obviously -xx will move text to the left of 0 (you won’t see the text if you do this.) So if you have a conky that is 1000 pixels wide, 0 is the left most pixel and 999 is the last one on the right.

${offset xx} moves it in a similar fashion but starts from where you use it.

Take a look at this three line example and the results, note the font used:

Line 1, has text out of place, but that ${goto 0} is going to assure that “This is” will be in the right place. And ${goto 54} will put “text.” at the end to form the phrase properly.

Lines #2 & 3, show what ${offset} does.

${font DejaVu Sans Mono:bold:size=9}
Line 1:
${goto 54}text.${goto 0}This is

Line 2:
This is${offset 80}text

Line 3:
${offset 80}text${goto 0}This is

As you see both lines #2 & 3 have the same command “${offset 80}text” but places “text” different positions on the line. NOTE: Personally I don’t use the ${offset} command but I’ve seen it used in various conkys in the forums.

Next we are going to look at ${voffset}

But before we get into it I want to point out that “every time” you use this command you create a blank empty space below your conky. It can not be helped to my knowledge. Here’s the reason, lets say you create a conky with 5 command lines below TEXT:

${font DejaVu Sans Mono:bold:size=9}line 1
line 2
line 3
line 4
line 5${font}

You are creating a conky that requires 5 lines (size determined by the font size you use) of space on your screen!

OK, so you want to use ${voffset} and move those lines up:

${font DejaVu Sans Mono:bold:size=9}line 1
${voffset -15}${goto 54}line 2
${voffset -15}${goto 108}line 3
${voffset -15}${goto 162}line 4
${voffset -15}${goto 216}line 5${font}

But you are still using 5 lines of code, even though you have “moved the display location”, that’s all you have done: “moved the display location” as seen below:


And for that reason we see things like this (See: Bars with text):


You can however put another conky on your screen to use that space. Just give it a sleep time of 1 or 2 seconds longer to allow the first conky with the space to load so the empty space “doesn’t cover” your second conky.

OK, lets continue with $voffset

${voffset xx} moves displayed output up or down, according to the "alignment" command used a positive number could be up or down and a negative number the opposite. For example with "alignment tl, tr, tm, bl, br or bm a voffset with a positive number will move the output further into the screen and a negative off the screen

Let’s look at an example:


NOTE: The following examples come from my working conky, I have removed the ${color} command to make it more easily readable.

${font woodbadge:size=40}IP:${font}
${font DejaVu Sans Mono:bold:size=9}Up:${upspeed eth0} k/s ${totalup eth0}
${addr eth0}
Down:${downspeed eth0} k/s ${totaldown eth0}${font}

As you see I’m using a LARGE font for IP: and the next three lines under that show UP: -speed and total, my IP address and Down: – speed and total in a smaller “mono” font because my spacing is a critical issue here.

What you get is 4 lines of output on your screen:

Up: 0 K/s 2.68M
Down: 0 k/s 9.34M

But we want it all on one line, so we need 3 x ${goto xx} and 1x ${voffset xx}. Why only 1 ${voffset} you ask. Simple; once used it moves “everything” up or down

First we play with the ${goto} command to get that 4th line moved over beyond the IP: display. Why that last line? “Down” has more characters than “Up” and is therefore easier to use as it’s placement will be “closer” then “Up”

${font woodbadge:size=40}IP:${font}
${font DejaVu Sans Mono:bold:size=9}Up:{upspeed eth0} k/s ${totalup eth0}
${addr eth0}
${goto 85}Down:{downspeed eth0} k/s ${totaldown eth0}

That looks good. Do line 3 now and play with line 2, I put the ${goto} after the ${font} command out of habit. It doesn’t really matter.

${font woodbadge:size=40}IP:${font}
${font DejaVu Sans Mono:bold:size=9}${goto 99}Up:{upspeed eth0} k/s ${totalup eth0}
${goto 85}${addr eth0}
${goto 85}Down:{downspeed eth0} k/s ${totaldown eth0}

OK, so everything lines up beyond the IP: now. Now we have to move it up with the ${voffset} command until we get the desired results. Placing the ${voffset} on that second line bringing all three up into place.

${font woodbadge:size=40}IP:${font}
${font DejaVu Sans Mono:bold:size=9}${voffset -45}${goto 99}Up:{upspeed eth0} k/s ${totalup eth0}
${goto 85}${addr eth0}
${goto 85}Down:{downspeed eth0} k/s ${totaldown eth0}

This is how it looks in my conky with all the codes:

${color2}${font woodbadge:size=40}IP:${font}${color}
${font DejaVu Sans Mono:bold:size=9}${voffset -45}${goto 99}${color9}Up:${color}${upspeed eth0} k/s ${totalup eth0}
${goto 85}${addr eth0}
${goto 85}${color3}Down:${color}${downspeed eth0} k/s ${totaldown eth0}${color}${font}

Thanks to Jackzor & djyoung4, for making me aware of this missing tidbit:

As you saw at the top of the page:

short_units yes
pad_percents 2

are two very useful variables and there is another that will help your conky look cleaner, neater, and just generally better if you use “Processes”

short_units yes
pad_percents 2
top_name_width 7

top_name_width – Width for $top_name value (defaults to 15 characters).

… so "top_name_width 7" will limit the processes names to “7″ characters allowing for exact spacing with goto’s.

The conky code below created the Processes conky you see on the left. Gotta love this decimals all lined up nice and neat!

default_color FFDEAD #NavajoWhite
color0 FFFFF0 #Ivory
color1 CD5C5C #IndianRed #00CED1 DarkTurquoise #FFA07A LightSalmon #00FFFF Cyan
color2 FF8C00 #Darkorange #D2691E #Chocolate
color3 7FFF00 #Chartreuse
color4 778899 #LightSlateGrey
color5 DCDCDC #Gainsboro
color6 00BFFF #DeepSkyBlue
#    colours below used by colorize script
color7 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #Red
pad_percents 2
top_name_width 7
minimum_size 120 100
${goto 10}${color4}${cpubar cpu0 25,160}
${voffset -33}${goto 20}${color0}${font dodger:size=15}CPU${font}${goto 120}${voffset -3}${font DejaVu Sans Mono:size=12}${cpu cpu0} %${font}
${voffset 10}${goto 10}${color3}Name${goto 85}CPU${goto 135}MEM${color}
${voffset 5}${goto 10}${top name 1}${goto 70}${top cpu 1}${goto 120}${top mem 1}
${goto 10}${top name 2}${goto 70}${top cpu 2}${goto 120}${top mem 2}
${goto 10}${top name 3}${goto 70}${top cpu 3}${goto 120}${top mem 3}
${goto 10}${top name 4}${goto 70}${top cpu 4}${goto 120}${top mem 4}
${goto 10}${top name 5}${goto 70}${top cpu 5}${goto 120}${top mem 5}
${goto 10}${top name 6}${goto 70}${top cpu 6}${goto 120}${top mem 6}
${goto 10}${top name 7}${goto 70}${top cpu 7}${goto 120}${top mem 7}
${goto 10}${top name 8}${goto 70}${top cpu 8}${goto 120}${top mem 8}
${goto 10}${top name 9}${goto 70}${top cpu 9}${goto 120}${top mem 9}
${goto 10}${voffset 33}${color4}${membar 25,160}
${voffset -33}${goto 20}${color0}${font dodger:size=15}MEM${font}${goto 120}${voffset -3}${font DejaVu Sans Mono:size=12}${memperc} %${font}
${voffset 10}${goto 10}${color3}Name${goto 85}CPU${goto 135}MEM${color}
${voffset 5}${goto 10}${top_mem name 1}${goto 70}${top_mem cpu 1}${goto 120}${top_mem mem 1}
${goto 10}${top_mem name 2}${goto 70}${top_mem cpu 2}${goto 120}${top_mem mem 2}
${goto 10}${top_mem name 3}${goto 70}${top_mem cpu 3}${goto 120}${top_mem mem 3}
${goto 10}${top_mem name 4}${goto 70}${top_mem cpu 4}${goto 120}${top_mem mem 4}
${goto 10}${top_mem name 5}${goto 70}${top_mem cpu 5}${goto 120}${top_mem mem 5}
${goto 10}${top_mem name 6}${goto 70}${top_mem cpu 6}${goto 120}${top_mem mem 6}
${goto 10}${top_mem name 7}${goto 70}${top_mem cpu 7}${goto 120}${top_mem mem 7}
${goto 10}${top_mem name 8}${goto 70}${top_mem cpu 8}${goto 120}${top_mem mem 8}
${goto 10}${top_mem name 9}${goto 70}${top_mem cpu 9}${goto 120}${top_mem mem 9}${font}${color}
Personal tools