From 3de12beef6ffacd252c5cc5d365969436311940d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 22 Nov 2010 00:07:52 +0100 Subject: [PATCH] make i3bar work with tree branch again (current_workspace is a string now) --- i3bar/src/outputs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/i3bar/src/outputs.c b/i3bar/src/outputs.c index 3577d82b..20ff8276 100644 --- a/i3bar/src/outputs.c +++ b/i3bar/src/outputs.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -102,6 +103,22 @@ static int outputs_integer_cb(void *params_, long val) { static int outputs_string_cb(void *params_, const unsigned char *val, unsigned int len) { struct outputs_json_params *params = (struct outputs_json_params*) params_; + if (!strcmp(params->cur_key, "current_workspace")) { + char *copy = malloc(sizeof(const unsigned char) * (len + 1)); + strncpy(copy, (const char*) val, len); + copy[len] = '\0'; + + char *end; + errno = 0; + long parsed_num = strtol(copy, &end, 10); + if (errno == 0 && + (end && *end == '\0')) + params->outputs_walk->ws = parsed_num; + free(copy); + FREE(params->cur_key); + return 1; + } + if (strcmp(params->cur_key, "name")) { return 0; }