If/Else statements in Conky

     So I use Conky to monitor my system and give me valuable information. I also switch between using WiFi and a direct Ethernet connection, for a long time I've only been able to see what kind of speed I have going with my WiFi through my Conky setup. I could have made a copy and had the Eth0 and Wlan0 speeds always showing, but that wastes space, on the desktop, not worried about the file size. Today I decided to see if I couldn't get some sort of if then setup in Conky, so I did what any true geek would do, did a Google search. I found that yes indeed this can be done.

#Networking
${if_up wlan0} # if the wlan0 interface is up
${font}${color2}Down ${downspeed wlan0} k/s ${alignr}Up ${upspeed wlan0} k/s
${color5}${downspeedgraph wlan0 15,70 color3} ${alignr}${upspeedgraph wlan0 15,70 color3}
${color2}${font}Total ${totaldown wlan0} ${alignr}Total ${totalup wlan0}
${voffset -20}
${else}
${if_up eth0} # if the eth0 interface is up
${voffset -25}
${font}${color2}Down ${downspeed eth0} k/s ${alignr}Up ${upspeed eth0} k/s
${color5}${downspeedgraph eth0 15,70 color3} ${alignr}${upspeedgraph eth0 15,70 color3}
${color2}${font}Total ${totaldown eth0} ${alignr}Total ${totalup eth0}
${voffset -30}
${else}
${endif}
${endif}

You'll notice I put in several ${voffset -#} strings, because each line takes space in the layout, even if it doesn't print any text, so by doing a negative offset you can compensate for that extra space. The values will change depending on the font and font size you use. Even with the fonts I use it changes a bit, however the amount is negligible and I can totally live with it.

You can download the entire setup/layout here.