summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@openbsd.org>2012-10-10 09:52:27 +0200
committerMichael Stapelberg <michael@stapelberg.de>2012-10-16 10:48:29 +0200
commited03d2450ceae3cc7952b65d8349373bbb45a487 (patch)
tree0db580c6639b4dca6d4d6c03ab9a8e11389d088e /src
parent04dc34f27d63eeda3e7f68a67151da97aeb5c2a8 (diff)
i3status - Handle down wireless interfaces just like ethernet interfaces (e.g. colors)
Diffstat (limited to 'src')
-rw-r--r--src/print_wireless_info.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c
index b5e7ba2..1eddd96 100644
--- a/src/print_wireless_info.c
+++ b/src/print_wireless_info.c
@@ -305,6 +305,15 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
INSTANCE(interface);
+ const char *ip_address = get_ip_addr(interface);
+ if (ip_address == NULL) {
+ START_COLOR("color_bad");
+ outwalk += sprintf(outwalk, "%s", format_down);
+ goto out;
+ } else {
+ START_COLOR("color_good");
+ }
+
if (get_wireless_info(interface, &info)) {
walk = format_up;
if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY)
@@ -366,9 +375,8 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
}
if (BEGINS_WITH(walk+1, "ip")) {
- const char *ip_address = get_ip_addr(interface);
- outwalk += sprintf(outwalk, "%s", (ip_address ? ip_address : "no IP"));
- walk += strlen("ip");
+ outwalk += sprintf(outwalk, "%s", ip_address);
+ walk += strlen("ip");
}
#ifdef LINUX
@@ -383,6 +391,7 @@ void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface,
#endif
}
+out:
END_COLOR;
OUTPUT_FULL_TEXT(buffer);
}