From: Michael Stapelberg Date: Sun, 21 Nov 2010 23:07:52 +0000 (+0100) Subject: make i3bar work with tree branch again (current_workspace is a string now) X-Git-Tag: 4.0.1~7^2~3^2~53 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3de12beef6ffacd252c5cc5d365969436311940d;p=i3%2Fi3 make i3bar work with tree branch again (current_workspace is a string now) --- 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; }