X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fprint_eth_info.c;h=9ad9b922e135e1c82144d9369c065c109ea76595;hb=3eec92d504444ad4f0c59b42ea961a3dedd9ebc2;hp=7624383b5f9e98c1e116168a7827b861e6f02e3d;hpb=f947d0a446b1b99020722cbc71127fc0c06086b2;p=i3%2Fi3status diff --git a/src/print_eth_info.c b/src/print_eth_info.c index 7624383..9ad9b92 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -74,11 +74,20 @@ static void print_eth_speed(const char *interface) { * Combines ethernet IP addresses and speed (if requested) for displaying * */ -void print_eth_info(const char *interface, const char *format) { +void print_eth_info(const char *interface, const char *format_up, const char *format_down) { const char *walk; const char *ip_address = get_ip_addr(interface); - for (walk = format; *walk != '\0'; walk++) { + if (ip_address == NULL) { + printf("%s", color("#FF0000")); + printf("%s", format_down); + (void)printf("%s", endcolor()); + return; + } else { + printf("%s", color("#00FF00")); + } + + for (walk = format_up; *walk != '\0'; walk++) { if (*walk != '%') { putchar(*walk); continue; @@ -92,4 +101,6 @@ void print_eth_info(const char *interface, const char *format) { walk += strlen("speed"); } } + + (void)printf("%s", endcolor()); }