diff options
Diffstat (limited to 'sway/commands/bar')
-rw-r--r-- | sway/commands/bar/hidden_state.c | 34 | ||||
-rw-r--r-- | sway/commands/bar/id.c | 2 | ||||
-rw-r--r-- | sway/commands/bar/mode.c | 34 | ||||
-rw-r--r-- | sway/commands/bar/status_command.c | 2 |
4 files changed, 33 insertions, 39 deletions
diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 502ce2c4..28adf6c7 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c @@ -32,7 +32,7 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar, } // free old mode free(old_state); - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + return NULL; } struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { @@ -50,24 +50,20 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { const char *state = argv[0]; if (config->reading) { - return bar_set_hidden_state(config->current_bar, state); - } - - const char *id = NULL; - if (argc == 2) { - id = argv[1]; - } - struct bar_config *bar; - for (int i = 0; i < config->bars->length; ++i) { - bar = config->bars->items[i]; - if (id && strcmp(id, bar->id) == 0) { - return bar_set_hidden_state(bar, state); - } - - error = bar_set_hidden_state(bar, state); - if (error) { - return error; + error = bar_set_hidden_state(config->current_bar, state); + } else { + const char *id = argc == 2 ? argv[1] : NULL; + for (int i = 0; i < config->bars->length; ++i) { + struct bar_config *bar = config->bars->items[i]; + if (id) { + if (strcmp(id, bar->id) == 0) { + error = bar_set_hidden_state(bar, state); + break; + } + } else if ((error = bar_set_hidden_state(bar, state))) { + break; + } } } - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c index 65fa69fd..7690a852 100644 --- a/sway/commands/bar/id.c +++ b/sway/commands/bar/id.c @@ -13,6 +13,8 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) { const char *oldname = config->current_bar->id; if (strcmp(name, oldname) == 0) { return cmd_results_new(CMD_SUCCESS, NULL, NULL); // NOP + } else if (strcmp(name, "id") == 0) { + return cmd_results_new(CMD_INVALID, "id", "id cannot be 'id'"); } // check if id is used by a previously defined bar for (int i = 0; i < config->bars->length; ++i) { diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 28e2d77b..dbdd3897 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -33,7 +33,7 @@ static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode // free old mode free(old_mode); - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + return NULL; } struct cmd_results *bar_cmd_mode(int argc, char **argv) { @@ -51,24 +51,20 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) { const char *mode = argv[0]; if (config->reading) { - return bar_set_mode(config->current_bar, mode); - } - - const char *id = NULL; - if (argc == 2) { - id = argv[1]; - } - - struct bar_config *bar; - for (int i = 0; i < config->bars->length; ++i) { - bar = config->bars->items[i]; - if (id && strcmp(id, bar->id) == 0) { - return bar_set_mode(bar, mode); - } - error = bar_set_mode(bar, mode); - if (error) { - return error; + error = bar_set_mode(config->current_bar, mode); + } else { + const char *id = argc == 2 ? argv[1] : NULL; + for (int i = 0; i < config->bars->length; ++i) { + struct bar_config *bar = config->bars->items[i]; + if (id) { + if (strcmp(id, bar->id) == 0) { + error = bar_set_mode(bar, mode); + break; + } + } else if ((error = bar_set_mode(bar, mode))) { + break; + } } } - return cmd_results_new(CMD_SUCCESS, NULL, NULL); + return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c index 5b4fdc87..490393f1 100644 --- a/sway/commands/bar/status_command.c +++ b/sway/commands/bar/status_command.c @@ -25,7 +25,7 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) { } if (config->active && !config->validating) { - load_swaybars(); + load_swaybar(config->current_bar); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); |