Conky ver 1.8.0-7.1; help with {if_match} statement

Greetings.

I’m trying to set up Conky and I’ve stuck on a problem.

I wish to have it display net traffic from eth0 or wlan0 (depending on which interface is active).

An {if_up wlan0} block works but it does not help when there’s no wireless net available. Therefore, I tried an {if_match} block.
The block of code is:

${if_match ${execpi 10 iwconfig wlan0 | grep "Access Point" | cut -c60-80}=="Not-Associated"}
IP on eth0 $alignr ${addr eth0}
Public IP: $alignr ${execi 3600 wget -O - http://whatismyip.org/ | tail}
Down: ${downspeed eth0}  ${alignr}Up:${upspeed eth0}
${upspeedgraph eth0 15,155 008000 ff0000 -t}  ${alignr}${downspeedgraph eth0 15,155 008000 ff0000 -t}
Downloaded: $alignr  ${totaldown eth0} 
Uploaded: $alignr  ${totalup eth0}
TCP Connections: $alignr ${tcp_portmon 1 65535 count}
${color #0077ff}Inbound Connection ${alignr} Local Service/Port${color lightgrey}
${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 lservice 0}
${tcp_portmon 1 65535 rhost 1} ${alignr} ${tcp_portmon 1 65535 lservice 1}
${else}
IP on wlan0 $alignr ${addr wlan0}
Public IP: $alignr ${execi 3600 wget -O - http://whatismyip.org/ | tail}
Down: ${downspeed wlan0}  ${alignr}Up:${upspeed wlan0}
${upspeedgraph wlan0 15,155 008000 ff0000 -t}  ${alignr}${downspeedgraph wlan0 15,155 008000 ff0000 -t}
Downloaded: $alignr  ${totaldown wlan0} 
Uploaded: $alignr  ${totalup wlan0}
TCP Connections: $alignr ${tcp_portmon 1 65535 count}
${color #0077ff}Inbound Connection ${alignr} Local Service/Port${color lightgrey}
 ${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 lservice 0}
 ${tcp_portmon 1 65535 rhost 1} ${alignr} ${tcp_portmon 1 65535 lservice 1}
 ${tcp_portmon 1 65535 rhost 2} ${alignr} ${tcp_portmon 1 65535 lservice 2}
${endif}

My logic behind this is to compare the output of the

iwconfig wlan0 |grep "Access Point" | cut -c60-80

command with a fixed string (in this case Not-Associated). If the machine is not connected to a wireless network, it goes on to display eth0 data. If it is connected to a wlan, Not-Associated isn’t the output and it should display wlan0 data.

If only it were so! :’(

I’ve been trying to figure it out how to solve it for a day and still nothing. If I remember well the ‘==’ operator compares two strings (right?). I’ve even tried ‘!=’ to no avail.

openSUSE 11.2 64bit
KDE 4.5.0
Kernel 2.6.31 desktop

Thanks in advance.
Any ideas?

Hi
I use if_empty;


${if_empty ${exec cat /proc/net/wireless| grep wlan0}}
${if_empty ${exec cat /proc/net/arp | grep eth0}}

Thanks for the reply.

${if_empty ${exec cat /proc/net/arp | grep eth0}}

works like a charm!:slight_smile: Thanks very much malcolmlewis. Now a few minor details and it’s all set for the screen shot thread! rotfl!

One final question:

${if_empty ${exec cat /proc/net/wireless| grep wlan0}}

does not work as intended. It always parses the 2nd arguement. :dont-know: Weird. Why could that be?

Maybe a transcription error but should there not be a space after wireless??

I don’t think this is the problem. I tried it with/without space. Still nothing.