+ fprintf(stderr, "[i3bar] Could not parse JSON input (code %d): %.*s\n",
+ status, length, input);
+ } else if (parser_context.has_urgent) {
+ has_urgent = true;
+ }
+ return has_urgent;
+}
+
+/*
+ * Callbalk for stdin. We read a line from stdin and store the result
+ * in statusline
+ *
+ */
+void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
+ int rec;
+ unsigned char *buffer = get_buffer(watcher, &rec);
+ if (buffer == NULL)
+ return;
+ bool has_urgent = false;
+ if (child.version > 0) {
+ has_urgent = read_json_input(buffer, rec);
+ } else {
+ read_flat_input((char*)buffer, rec);
+ }
+ free(buffer);
+ draw_bars(has_urgent);
+}
+
+/*
+ * Callbalk for stdin first line. We read the first line to detect
+ * whether this is JSON or plain text
+ *
+ */
+void stdin_io_first_line_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
+ int rec;
+ unsigned char *buffer = get_buffer(watcher, &rec);
+ if (buffer == NULL)
+ return;
+ DLOG("Detecting input type based on buffer *%.*s*\n", rec, buffer);
+ /* Detect whether this is JSON or plain text. */
+ unsigned int consumed = 0;
+ /* At the moment, we don’t care for the version. This might change
+ * in the future, but for now, we just discard it. */
+ parse_json_header(&child, buffer, rec, &consumed);
+ if (child.version > 0) {
+ /* If hide-on-modifier is set, we start of by sending the
+ * child a SIGSTOP, because the bars aren't mapped at start */
+ if (config.hide_on_modifier) {
+ stop_child();