From d5b4c8e368050cf1b84b03c1379bbbc3c817a713 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 16 Feb 2012 23:29:29 +0000 Subject: Implement the i3bar JSON protocol This hardcodes all the JSON parts. Strings are not properly escaped currently. The best/easiest way to fix this is by actually using libyajl. --- src/print_wireless_info.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/print_wireless_info.c') diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 1aca346..530d9cf 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -224,6 +224,9 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) { void print_wireless_info(const char *interface, const char *format_up, const char *format_down) { const char *walk; wireless_info_t info; + if (output_format == O_I3BAR) + printf("{\"name\":\"wireless\", \"instance\": \"%s\", ", interface); + if (get_wireless_info(interface, &info)) { walk = format_up; if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) @@ -234,6 +237,9 @@ void print_wireless_info(const char *interface, const char *format_up, const cha printf("%s", color("color_bad")); } + if (output_format == O_I3BAR) + printf("\"full_text\":\""); + for (; *walk != '\0'; walk++) { if (*walk != '%') { putchar(*walk); @@ -308,4 +314,7 @@ void print_wireless_info(const char *interface, const char *format_up, const cha } (void)printf("%s", endcolor()); + + if (output_format == O_I3BAR) + printf("\"}"); } -- cgit v1.2.3