I'm not a coder, just someone who is trying to work with conky for default distribution with a Linux distro. Here I am trying to get automatic net setup.

  1. Following posts here and elsewhere, I am able to print the active network interface with this line:

    ${color2}ACTIVE: ${color3}${execi -300 netup}${color}

The "netup" refers to a small script in /usr/local/bin/ that has a single line:

ip addr show | awk '/inet.*brd/{print $NF; exit}'

In my case that conky line produces on the screen: ACTIVE: interface_name (see image below). So far, so excellent.

  1. Now I would like to replace an interface-specific command about traffic or any other net info with the name that that script outputs, which would save me and the user a certain amount of hassle. I tried this, which works fine if wlan0 etc. is used:

    Down: ${downspeedf netup}kB/s ${alignr}Up: ${upspeedf netup}kB/s ${downspeedgraph netup 30,120 000000 000000} ${alignr}${upspeedgraph netup 30,120 000000 000000}

That clearly isn't correct, b/c the graph shows but has no content. net graphs with no content

Two questions: 1) is there a way to read the active interface that was just written one line earlier?; 2) if not, how can I incorporate the output of the netup script in those down and up graphs?

Appreciate any help.



What you can do is call eval to delay the call of upspeedf and so on until you have called your script and it has returned the name of the interface.

For example,

${eval $${downspeedgraph ${exec netup} 30,120 000000 000000} } 
${eval $${upspeedgraph   ${exec netup} 30,120 000000 000000} }

Note the doubling of $ which will become a single $ for the eval. Unfortunately, your script will be called on each update cycle, so you may want to optimise your script. There is no difference if you use execi with an interval.

For full versatility, you will need to use a lua function, which is quite a lot to learn. If your interface only needs to be determined once at the start, then why not write a small startup script to find the interface name and edit the .conkyrc file with that name before running conky.

Note, ${eval} is broken in version 1.10 until this patch which I think is for 1.10.3 or .4.

| improve this answer | |
  • Lua is way out of my range, so I think I will try the startup script first. Thanks. – Jerry Bond Nov 25 '17 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.