diff options
Diffstat (limited to 'i3bar/src/config.c')
-rw-r--r-- | i3bar/src/config.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/i3bar/src/config.c b/i3bar/src/config.c index ccea937d..cebd5d5d 100644 --- a/i3bar/src/config.c +++ b/i3bar/src/config.c @@ -188,11 +188,17 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len } if (!strcmp(cur_key, "status_command")) { - DLOG("command = %.*s\n", len, val); + DLOG("status_command = %.*s\n", len, val); sasprintf(&config.command, "%.*s", len, val); return 1; } + if (!strcmp(cur_key, "workspace_command")) { + DLOG("workspace_command = %.*s\n", len, val); + sasprintf(&config.workspace_command, "%.*s", len, val); + return 1; + } + if (!strcmp(cur_key, "font")) { DLOG("font = %.*s\n", len, val); FREE(config.fontname); @@ -396,16 +402,15 @@ static yajl_callbacks outputs_callbacks = { }; /* - * Start parsing the received bar configuration JSON string + * Parse the received bar configuration JSON string * */ -void parse_config_json(char *json) { - yajl_handle handle = yajl_alloc(&outputs_callbacks, NULL, NULL); - +void parse_config_json(const unsigned char *json, size_t size) { TAILQ_INIT(&(config.bindings)); TAILQ_INIT(&(config.tray_outputs)); - yajl_status state = yajl_parse(handle, (const unsigned char *)json, strlen(json)); + yajl_handle handle = yajl_alloc(&outputs_callbacks, NULL, NULL); + yajl_status state = yajl_parse(handle, json, size); /* FIXME: Proper error handling for JSON parsing */ switch (state) { @@ -418,6 +423,11 @@ void parse_config_json(char *json) { break; } + if (config.disable_ws && config.workspace_command) { + ELOG("You have specified 'workspace_buttons no'. Your 'workspace_command %s' will be ignored.\n", config.workspace_command); + FREE(config.workspace_command); + } + yajl_free(handle); } @@ -427,16 +437,16 @@ static int i3bar_config_string_cb(void *params_, const unsigned char *val, size_ } /* - * Start parsing the received bar configuration list. The only usecase right - * now is to automatically get the first bar id. + * Parse the received bar configuration list. The only usecase right now is to + * automatically get the first bar id. * */ -void parse_get_first_i3bar_config(char *json) { +void parse_get_first_i3bar_config(const unsigned char *json, size_t size) { yajl_callbacks configs_callbacks = { .yajl_string = i3bar_config_string_cb, }; yajl_handle handle = yajl_alloc(&configs_callbacks, NULL, NULL); - yajl_parse(handle, (const unsigned char *)json, strlen(json)); + yajl_parse(handle, json, size); yajl_free(handle); } |