<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[dynamic - Matthias Lee - Musings on Software and Performance Engineering]]></title><description><![CDATA[Matthias Lee is a Software Performance Engineer, Technical Lead and Computer Science PhD. Currently a Principal Performance Engineer at Appian.]]></description><link>https://matthiaslee.com/</link><image><url>https://matthiaslee.com/favicon.png</url><title>dynamic - Matthias Lee - Musings on Software and Performance Engineering</title><link>https://matthiaslee.com/</link></image><generator>Ghost 2.14</generator><lastBuildDate>Sat, 29 Nov 2025 00:45:51 GMT</lastBuildDate><atom:link href="https://matthiaslee.com/tag/dynamic/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Dynamically changing conky network interface]]></title><description><![CDATA[<p>I use conky on many of my machines, most desktop machines will have one or two network interfaces which I want to always monitor, but my laptop I often switch between many different network interfaces, (eth0, wlan0, usb0 and tun0), and I really like Conky's downspeedgraph and upspeedgraph. The issue</p>]]></description><link>https://matthiaslee.com/dynamically-changing-conky-network-interface/</link><guid isPermaLink="false">5a0a60d882e47c00018dabe3</guid><category><![CDATA[conky]]></category><category><![CDATA[network interface]]></category><category><![CDATA[dynamic]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[Matthias A. Lee]]></dc:creator><pubDate>Sun, 03 Aug 2014 17:28:42 GMT</pubDate><content:encoded><![CDATA[<p>I use conky on many of my machines, most desktop machines will have one or two network interfaces which I want to always monitor, but my laptop I often switch between many different network interfaces, (eth0, wlan0, usb0 and tun0), and I really like Conky's downspeedgraph and upspeedgraph. The issue is I dont want to be displaying all interfaces at all times. I only want to display the interfaces I am currently using.</p>
<p>I went to consult the Conky Doc (<a href="http://conky.sourceforge.net/variables.html">http://conky.sourceforge.net/variables.html</a>) at first I came across:</p>
<pre><code>${if_up &lt;iface&gt;} ${endif}
</code></pre>
<p>Which switches conky config blocks based on which interfaces are up.<br>
This is great, but still always displays eth0 and wlan0 as long as the interfaces are enabled, even if they are not connected to anything.<br>
Next I found:</p>
<pre><code>${if_existing /sys/class/net/&lt;iface&gt;/operstate up} ${endif}
</code></pre>
<p>This will automatically switch blocks of your config only when an interface's &quot;operstate&quot; is &quot;up&quot;. Surprisingly this is different from the <code>${if_up &lt;iface&gt;}</code> statement and at least for me this produces the expected behavior.</p>
<p>I ended up using a combination of the <code>${if_up}</code> and <code>${if_existing}</code> mainly because for temporary interfaces such as usb0 and tun0 the  <code>${if_up}</code> statement works fine and looks cleaner.</p>
<h4 id="hereismycurrentconfig">Here is my current config:</h4>
<pre><code>Network ${hr}
${if_existing /sys/class/net/eth0/operstate up}
eth0
Down ${downspeed eth0} k/s ${alignr}Up ${upspeed eth0} k/s
${downspeedgraph eth0 25,100 dddddd ffffff 150} ${alignr}${upspeedgraph eth0 25,100 dddddd ffffff 18}
Total ${totaldown eth0} ${alignr}Total ${totalup eth0}
${endif}${if_existing /sys/class/net/wlan0/operstate up}
wlan0
Down ${downspeed wlan0} k/s ${alignr}Up ${upspeed wlan0} k/s
${downspeedgraph wlan0 25,100 dddddd ffffff 150} ${alignr}${upspeedgraph wlan0 25,100 dddddd ffffff 18}
Total ${totaldown wlan0} ${alignr}Total ${totalup wlan0}
${endif}${if_up usb0}
usb0
Down ${downspeed usb0} k/s ${alignr}Up ${upspeed usb0} k/s
${downspeedgraph usb0 25,100 dddddd ffffff 150} ${alignr}${upspeedgraph usb0 25,100 dddddd ffffff 18}
Total ${totaldown usb0} ${alignr}Total ${totalup usb0}
${endif}${if_up tun0}
tun0
Down ${downspeed tun0} k/s ${alignr}Up ${upspeed tun0} k/s
${downspeedgraph tun0 25,100 dddddd ffffff 150} ${alignr}${upspeedgraph tun0 25,100 dddddd ffffff 18}
Total ${totaldown tun0} ${alignr}Total ${totalup tun0}
${endif}
</code></pre>
<p>enjoy.</p>
]]></content:encoded></item></channel></rss>