diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-02-24 13:34:47 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-02-24 13:34:47 -0500 |
commit | 2154b7c7d623d99e2623f1928f6e77e95255a2d3 (patch) | |
tree | a57176801941d44a9bd6ac4e3d776f2f905a4f38 | |
parent | 7262bf655f7a19af1d4c8681be74d70bfc6b8911 (diff) |
add config handlers
-rw-r--r-- | sway/commands.c | 19 | ||||
-rw-r--r-- | sway/commands/set.c | 1 |
2 files changed, 18 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c index ed8da3dc..b52eb200 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -138,11 +138,18 @@ static struct cmd_handler handlers[] = { { "input", cmd_input }, { "output", cmd_output }, { "seat", cmd_seat }, - { "set", cmd_set }, { "workspace", cmd_workspace }, }; /** + * Commands that can *only* run in the config loading context + * Keep alphabetized + */ +static struct cmd_handler config_handlers[] = { + { "set", cmd_set }, +}; + +/** * Commands that can *not* run in the config loading context * Keep alphabetized */ @@ -215,6 +222,16 @@ static struct cmd_handler *find_handler(char *line, enum cmd_status block) { } } + if (config->reading) { + res = bsearch(&d, config_handlers, + sizeof(config_handlers) / sizeof(struct cmd_handler), + sizeof(struct cmd_handler), handler_compare); + + if (res) { + return res; + } + } + res = bsearch(&d, handlers, sizeof(handlers) / sizeof(struct cmd_handler), sizeof(struct cmd_handler), handler_compare); diff --git a/sway/commands/set.c b/sway/commands/set.c index 856c73e7..84e9b792 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c @@ -27,7 +27,6 @@ void free_sway_variable(struct sway_variable *var) { struct cmd_results *cmd_set(int argc, char **argv) { char *tmp; struct cmd_results *error = NULL; - if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { return error; } |