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_run_watch.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/print_run_watch.c') diff --git a/src/print_run_watch.c b/src/print_run_watch.c index 455130e..c806d8e 100644 --- a/src/print_run_watch.c +++ b/src/print_run_watch.c @@ -6,8 +6,14 @@ void print_run_watch(const char *title, const char *pidfile, const char *format) bool running = process_runs(pidfile); const char *walk; + if (output_format == O_I3BAR) + printf("{\"name\":\"run_watch\", \"instance\": \"%s\", ", pidfile); + printf("%s", (running ? color("color_good") : color("color_bad"))); + if (output_format == O_I3BAR) + printf("\"full_text\":\""); + for (walk = format; *walk != '\0'; walk++) { if (*walk != '%') { putchar(*walk); @@ -24,4 +30,7 @@ void print_run_watch(const char *title, const char *pidfile, const char *format) } printf("%s", endcolor()); + + if (output_format == O_I3BAR) + printf("\"}"); } -- cgit v1.2.3