diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/exec.c | 7 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 20 |
2 files changed, 21 insertions, 6 deletions
diff --git a/sway/commands/exec.c b/sway/commands/exec.c index 87d90716..2c6f3d2d 100644 --- a/sway/commands/exec.c +++ b/sway/commands/exec.c @@ -5,12 +5,15 @@ #include "stringop.h" struct cmd_results *cmd_exec(int argc, char **argv) { - if (!config->active) return cmd_results_new(CMD_DEFER, NULL); + struct cmd_results *error = NULL; + if ((error = cmd_exec_validate(argc, argv))) { + return error; + } if (config->reloading) { char *args = join_args(argv, argc); sway_log(SWAY_DEBUG, "Ignoring 'exec %s' due to reload", args); free(args); return cmd_results_new(CMD_SUCCESS, NULL); } - return cmd_exec_always(argc, argv); + return cmd_exec_process(argc, argv); } diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index a5724295..39e48a44 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -13,15 +13,19 @@ #include "log.h" #include "stringop.h" -struct cmd_results *cmd_exec_always(int argc, char **argv) { +struct cmd_results *cmd_exec_validate(int argc, char **argv) { struct cmd_results *error = NULL; - if (!config->active || config->validating) { - return cmd_results_new(CMD_DEFER, NULL); - } if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { return error; } + if (!config->active || config->validating) { + return cmd_results_new(CMD_DEFER, NULL); + } + return error; +} +struct cmd_results *cmd_exec_process(int argc, char **argv) { + struct cmd_results *error = NULL; char *tmp = NULL; if (strcmp(argv[0], "--no-startup-id") == 0) { sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored."); @@ -92,3 +96,11 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { return cmd_results_new(CMD_SUCCESS, NULL); } + +struct cmd_results *cmd_exec_always(int argc, char **argv) { + struct cmd_results *error; + if ((error = cmd_exec_validate(argc, argv))) { + return error; + } + return cmd_exec_process(argc, argv); +} |