Search code examples
if-statementconky

if-else statement in conky not working properly


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?


Solution

  • 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}