summaryrefslogtreecommitdiff
path: root/src/print_time.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-02-16 23:29:29 +0000
committerMichael Stapelberg <michael@stapelberg.de>2012-02-16 23:30:54 +0000
commitd5b4c8e368050cf1b84b03c1379bbbc3c817a713 (patch)
tree2f918d4c5b95a05ebec68bceec35f7d4fa9a0c4e /src/print_time.c
parent7149f6f78e0d105f02d54e1db60db8b191a98acb (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_time.c')
-rw-r--r--src/print_time.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/print_time.c b/src/print_time.c
index 9c9df90..3c48d3f 100644
--- a/src/print_time.c
+++ b/src/print_time.c
@@ -3,12 +3,18 @@
#include <stdio.h>
#include <stdlib.h>
+#include "i3status.h"
+
void print_time(const char *format, struct tm *current_tm) {
static char part[512];
/* Get date & time */
if (current_tm == NULL) {
return;
}
+ if (output_format == O_I3BAR)
+ printf("{\"name\":\"time\", \"full_text\":\"");
(void)strftime(part, sizeof(part), format, current_tm);
printf("%s", part);
+ if (output_format == O_I3BAR)
+ printf("\"}");
}