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_cpu_temperature.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/print_cpu_temperature.c') diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c index 8c343c2..08fac88 100644 --- a/src/print_cpu_temperature.c +++ b/src/print_cpu_temperature.c @@ -31,6 +31,9 @@ void print_cpu_temperature_info(int zone, const char *path, const char *format) path = thermal_zone; } + if (output_format == O_I3BAR) + printf("{\"name\":\"cpu_temperature\", \"instance\": \"%s\", \"full_text\":\"", path); + for (walk = format; *walk != '\0'; walk++) { if (*walk != '%') { putchar(*walk); @@ -58,6 +61,10 @@ void print_cpu_temperature_info(int zone, const char *path, const char *format) walk += strlen("degrees"); } } + + if (output_format == O_I3BAR) + printf("\"}"); + return; error: #endif -- cgit v1.2.3