From: Dmitrij D. Czarkoff Date: Thu, 6 Aug 2015 15:14:38 +0000 (+0200) Subject: Use "color_degraded" when interface has no IP X-Git-Tag: 2.10~23^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9b238a8d65c5fd444422a3f32ce98b6631c88377;p=i3%2Fi3status Use "color_degraded" when interface has no IP On laptops one may want to have all interfaces up in order to let network prioritization manage switching between wired and wireless connection. In such cases lack of IP address is a useful hint about currently used interface, and color-coding makes it stand out more. --- diff --git a/src/print_eth_info.c b/src/print_eth_info.c index 06a1613..e2326b5 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -126,7 +126,10 @@ void print_eth_info(yajl_gen json_gen, char *buffer, const char *interface, cons goto out; } - START_COLOR("color_good"); + if (BEGINS_WITH(ip_address, "no IP")) + START_COLOR("color_degraded"); + else + START_COLOR("color_good"); for (walk = format_up; *walk != '\0'; walk++) { if (*walk != '%') { diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 8b390ab..83c717e 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -342,7 +342,7 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) START_COLOR((info.quality < info.quality_average ? "color_degraded" : "color_good")); else - START_COLOR("color_good"); + START_COLOR((BEGINS_WITH(ip_address, "no IP") ? "color_degraded" : "color_good")); } else { walk = format_down; START_COLOR("color_bad");