Implement the i3bar JSON protocol (with fallback to plain text)

If the first line of the input starts with {"version":, then the input is
considered to be JSON, otherwise it is interpreted as plain text.

Only the "full_text" and "color" parts of a block are currently understood by
i3bar.
This commit is contained in:
Michael Stapelberg
2012-02-16 23:27:11 +00:00
parent a6c461264c
commit 31b9d24c2b
3 changed files with 188 additions and 26 deletions

View File

@ -9,6 +9,9 @@
#define COMMON_H_
#include <stdbool.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
#include "queue.h"
typedef struct rect_t rect;
@ -23,7 +26,27 @@ struct rect_t {
int h;
};
#include "queue.h"
/* This data structure represents one JSON dictionary, multiple of these make
* up one status line. */
struct status_block {
char *full_text;
char *color;
/* full_text, but converted to UCS-2. This variable is only temporarily
* used in refresh_statusline(). */
xcb_char2b_t *ucs2_full_text;
size_t glyph_count_full_text;
/* The amount of pixels necessary to render this block. This variable is
* only temporarily used in refresh_statusline(). */
uint32_t width;
TAILQ_ENTRY(status_block) blocks;
};
TAILQ_HEAD(statusline_head, status_block) statusline_head;
#include "child.h"
#include "ipc.h"
#include "outputs.h"