0

my if-elseif-else construct in conky is not working properly. It should display "wireless" when I am connect to a wifi, "wired" when I am connected to a wired lan and "no network", when I have no network connection. This is my conky-code which is not working properly:

${if_existing /proc/net/route wlan0}${color grey}wireless\
${else}\
${if_existing /proc/net/route eth0}${color grey}wired\
${else}\
${color grey}no network\
${endif}

The problem is that if I do have a wireless connection, nothing from my conkyrc after the lines written above is executed. If there is no network connection, it is working.

What is working though, is if I only use one if-else construct:

${if_existing /proc/net/route wlan0}${color grey}wireless\
${else}\
${color grey}no network\
${endif}

What am I doing wrong in the first snippet?

Alf
  • 1,821
  • 3
  • 30
  • 48

2 Answers2

1

well, the answer is quite simple... I was not aware that I need to close every single if separately. So, here is the working code:

${if_existing /proc/net/route wlan0}${color grey}wireless\    
${else}\
${if_existing /proc/net/route eth0}${color grey}wired\
${else}\
${color grey}no network\
${endif}\
${endif}
Alf
  • 1,821
  • 3
  • 30
  • 48
1

If it can be of any help, here is the structure of my usb conky (4 different usb and a "no usb" condition) :

${if_existing /media/me/1}1${fs_used_perc /media/me/1}%${else}\
${if_existing /media/me/2}2${fs_used_perc /media/me/2}%${else}\
${if_existing /media/me/3}3${fs_used_perc /media/me/3}%${else}\
${if_existing /media/me/4}4${fs_used_perc /media/me/4}%${else}\
No Usb${endif}${endif}${endif}${endif}
l76b
  • 11
  • 1
  • yeah, that's the same line as my answer: every `if` needs to be closed explicitly – Alf Nov 01 '16 at 11:06