diff --git a/sway/commands.c b/sway/commands.c index 13a2d0b68..8e92740d9 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -41,14 +41,12 @@ bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { binding->command = join_args(argv + 1, argc - 1); //Set the first workspace name found to the init_workspace - list_t *cargs = split_string(binding->command, " "); if (!config->init_workspace) { - if (strcmp("workspace", cargs->items[0]) == 0) { - argv[0] = do_var_replacement(config, argv[0]); - config->init_workspace = do_var_replacement(config, cargs->items[1]); + if (strcmp("workspace", argv[1]) == 0) { + config->init_workspace = malloc(strlen(argv[2]) + 1); + strcpy(config->init_workspace, argv[2]); } } - list_free(cargs); list_t *split = split_string(argv[0], "+"); int i; @@ -391,7 +389,10 @@ bool handle_command(struct sway_config *config, char *exec) { char **argv = split_directive(exec + strlen(handler->command), &argc); int i; - argv[0] = do_var_replacement(config, argv[0]); + //Perform var subs on all parts of the command + for (i = 0; i < argc; ++i) { + argv[i] = do_var_replacement(config, argv[i]); + } exec_success = handler->handle(config, argc, argv); for (i = 0; i < argc; ++i) { diff --git a/sway/config.c b/sway/config.c index 8b4221de9..7fbd7a69d 100644 --- a/sway/config.c +++ b/sway/config.c @@ -90,7 +90,9 @@ _continue: if (!config->init_workspace) { sway_log(L_INFO, "No workspace names set, defaulting to 1"); - config->init_workspace = "1"; + char* default_init_workspace = "1"; + config->init_workspace = malloc(strlen(default_init_workspace) + 1); + strcpy(config->init_workspace, default_init_workspace); } return config;