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_volume.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/print_volume.c') diff --git a/src/print_volume.c b/src/print_volume.c index c13cb17..85b6176 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -43,6 +43,8 @@ static void free_hdl(struct mixer_hdl *hdl) { void print_volume(const char *fmt, const char *device, const char *mixer, int mixer_idx) { /* Printing volume only works with ALSA at the moment */ + if (output_format == O_I3BAR) + printf("{\"name\":\"volume\", \"instance\": \"%s.%s.%d\", \"full_text\":\"", device, mixer, mixer_idx); #ifdef LINUX /* Check if we already opened the mixer and get the handle * from cache if so */ @@ -180,4 +182,6 @@ void print_volume(const char *fmt, const char *device, const char *mixer, int mi } close(mixfd); #endif + if (output_format == O_I3BAR) + printf("\"}"); } -- cgit v1.2.3