From 71bcee4f96206e9988bc9a1302f6e1fff4526ce3 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Sat, 17 Oct 2015 14:28:38 +0200 Subject: [PATCH 1/2] commands: Ignore exec switch "--no-startup-id". When using an i3 config verbatim in sway this switch to exec or exec_always might appear. Before this patch the switch would be passed to /bin/sh, causing an error, and the command would not be run. --- sway/commands.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 2358b9e9..41223937 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -186,8 +186,16 @@ static enum cmd_status cmd_exec_always(int argc, char **argv) { if (!checkarg(argc, "exec_always", EXPECTED_MORE_THAN, 0)) { return CMD_FAILURE; } + + char *tmp = NULL; + if (strcmp((char*)*argv, "--no-startup-id") == 0) { + sway_log(L_INFO, "exec switch '--no-startup-id' not supported, ignored."); + tmp = join_args(argv + 1, argc - 1); + } else { + tmp = join_args(argv, argc); + } + // Put argument into cmd array - char *tmp = join_args(argv, argc); char cmd[4096]; strcpy(cmd, tmp); free(tmp); From 71ebe8c36be6c702654ad550aa2e897d03b4e98f Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Sun, 18 Oct 2015 19:14:49 +0200 Subject: [PATCH 2/2] commands: Catch empty exec with --no-startup-id cases. --- sway/commands.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sway/commands.c b/sway/commands.c index 41223937..5afddc4a 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -190,6 +190,11 @@ static enum cmd_status cmd_exec_always(int argc, char **argv) { char *tmp = NULL; if (strcmp((char*)*argv, "--no-startup-id") == 0) { sway_log(L_INFO, "exec switch '--no-startup-id' not supported, ignored."); + + if (!checkarg(argc - 1, "exec_always", EXPECTED_MORE_THAN, 0)) { + return CMD_FAILURE; + } + tmp = join_args(argv + 1, argc - 1); } else { tmp = join_args(argv, argc);