Changed command handler to perform var subs on all portions of a command

This commit is contained in:
Luminarys 2015-08-11 11:24:56 -05:00
parent 0356ab3eba
commit fcfcffa1ea
2 changed files with 10 additions and 7 deletions

View file

@ -41,14 +41,12 @@ bool cmd_bindsym(struct sway_config *config, int argc, char **argv) {
binding->command = join_args(argv + 1, argc - 1); binding->command = join_args(argv + 1, argc - 1);
//Set the first workspace name found to the init_workspace //Set the first workspace name found to the init_workspace
list_t *cargs = split_string(binding->command, " ");
if (!config->init_workspace) { if (!config->init_workspace) {
if (strcmp("workspace", cargs->items[0]) == 0) { if (strcmp("workspace", argv[1]) == 0) {
argv[0] = do_var_replacement(config, argv[0]); config->init_workspace = malloc(strlen(argv[2]) + 1);
config->init_workspace = do_var_replacement(config, cargs->items[1]); strcpy(config->init_workspace, argv[2]);
} }
} }
list_free(cargs);
list_t *split = split_string(argv[0], "+"); list_t *split = split_string(argv[0], "+");
int i; int i;
@ -391,7 +389,10 @@ bool handle_command(struct sway_config *config, char *exec) {
char **argv = split_directive(exec + strlen(handler->command), &argc); char **argv = split_directive(exec + strlen(handler->command), &argc);
int i; 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); exec_success = handler->handle(config, argc, argv);
for (i = 0; i < argc; ++i) { for (i = 0; i < argc; ++i) {

View file

@ -90,7 +90,9 @@ _continue:
if (!config->init_workspace) { if (!config->init_workspace) {
sway_log(L_INFO, "No workspace names set, defaulting to 1"); 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; return config;