diff options
author | Orestis Floros <orestisflo@gmail.com> | 2023-01-22 18:34:14 +0100 |
---|---|---|
committer | Orestis Floros <orestisflo@gmail.com> | 2023-01-22 18:34:14 +0100 |
commit | ff30991b16c9b62cf5f04353f419b09912b83ede (patch) | |
tree | 4928f60370ebd34bc942a7e00867e37422ba8d1e /i3bar/src/config.c | |
parent | c52f13900df5da04d86809abbfe25178a4bbe305 (diff) | |
download | i3-ff30991b16c9b62cf5f04353f419b09912b83ede.tar.gz i3-ff30991b16c9b62cf5f04353f419b09912b83ede.zip |
i3bar: Add protocol for workspace buttonsi3bar-ws-protocol
Closes #3818 (parent issue)
Fixes #1808
Fixes #2333
Fixes #2617
Fixes #3548
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); } |