Results 1 to 5 of 5

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

  1. #1
    Join Date
    Nov 2009
    Location
    Syros island, Greece
    Posts
    19

    Question 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:

    Code:
    ${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

    Code:
    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?

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    28,172
    Blog Entries
    15

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

    Hi
    I use if_empty;
    Code:
    ${if_empty ${exec cat /proc/net/wireless| grep wlan0}}
    ${if_empty ${exec cat /proc/net/arp | grep eth0}}
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3
    Join Date
    Nov 2009
    Location
    Syros island, Greece
    Posts
    19

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

    Quote Originally Posted by malcolmlewis View Post
    Hi
    I use if_empty;
    Code:
    ${if_empty ${exec cat /proc/net/wireless| grep wlan0}}
    ${if_empty ${exec cat /proc/net/arp | grep eth0}}

    Thanks for the reply.

    Code:
    ${if_empty ${exec cat /proc/net/arp | grep eth0}}
    works like a charm! Thanks very much malcolmlewis. Now a few minor details and it's all set for the screen shot thread!

    One final question:

    Code:
    ${if_empty ${exec cat /proc/net/wireless| grep wlan0}}
    does not work as intended. It always parses the 2nd arguement. Weird. Why could that be?

  4. #4
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,816

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

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

  5. #5
    Join Date
    Nov 2009
    Location
    Syros island, Greece
    Posts
    19

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

    Quote Originally Posted by gogalthorp View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •