diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2012-02-16 23:29:29 +0000 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2012-02-16 23:30:54 +0000 |
commit | d5b4c8e368050cf1b84b03c1379bbbc3c817a713 (patch) | |
tree | 2f918d4c5b95a05ebec68bceec35f7d4fa9a0c4e /src/print_wireless_info.c | |
parent | 7149f6f78e0d105f02d54e1db60db8b191a98acb (diff) |
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.
Diffstat (limited to 'src/print_wireless_info.c')
-rw-r--r-- | src/print_wireless_info.c | 9 |
1 files changed, 9 insertions, 0 deletions
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("\"}"); } |