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 /sway | |
parent | remove checks for command handlers (diff) | |
download | sway-2154b7c7d623d99e2623f1928f6e77e95255a2d3.tar.gz sway-2154b7c7d623d99e2623f1928f6e77e95255a2d3.tar.zst sway-2154b7c7d623d99e2623f1928f6e77e95255a2d3.zip |
add config handlers
Diffstat (limited to 'sway')
-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[] = { | |||
138 | { "input", cmd_input }, | 138 | { "input", cmd_input }, |
139 | { "output", cmd_output }, | 139 | { "output", cmd_output }, |
140 | { "seat", cmd_seat }, | 140 | { "seat", cmd_seat }, |
141 | { "set", cmd_set }, | ||
142 | { "workspace", cmd_workspace }, | 141 | { "workspace", cmd_workspace }, |
143 | }; | 142 | }; |
144 | 143 | ||
145 | /** | 144 | /** |
145 | * Commands that can *only* run in the config loading context | ||
146 | * Keep alphabetized | ||
147 | */ | ||
148 | static struct cmd_handler config_handlers[] = { | ||
149 | { "set", cmd_set }, | ||
150 | }; | ||
151 | |||
152 | /** | ||
146 | * Commands that can *not* run in the config loading context | 153 | * Commands that can *not* run in the config loading context |
147 | * Keep alphabetized | 154 | * Keep alphabetized |
148 | */ | 155 | */ |
@@ -215,6 +222,16 @@ static struct cmd_handler *find_handler(char *line, enum cmd_status block) { | |||
215 | } | 222 | } |
216 | } | 223 | } |
217 | 224 | ||
225 | if (config->reading) { | ||
226 | res = bsearch(&d, config_handlers, | ||
227 | sizeof(config_handlers) / sizeof(struct cmd_handler), | ||
228 | sizeof(struct cmd_handler), handler_compare); | ||
229 | |||
230 | if (res) { | ||
231 | return res; | ||
232 | } | ||
233 | } | ||
234 | |||
218 | res = bsearch(&d, handlers, | 235 | res = bsearch(&d, handlers, |
219 | sizeof(handlers) / sizeof(struct cmd_handler), | 236 | sizeof(handlers) / sizeof(struct cmd_handler), |
220 | sizeof(struct cmd_handler), handler_compare); | 237 | 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) { | |||
27 | struct cmd_results *cmd_set(int argc, char **argv) { | 27 | struct cmd_results *cmd_set(int argc, char **argv) { |
28 | char *tmp; | 28 | char *tmp; |
29 | struct cmd_results *error = NULL; | 29 | struct cmd_results *error = NULL; |
30 | if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); | ||
31 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { | 30 | if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { |
32 | return error; | 31 | return error; |
33 | } | 32 | } |