mirror of
https://github.com/swaywm/sway.git
synced 2024-11-18 14:09:14 +00:00
Merge pull request #2084 from RedSoxFan/runtime-var-expansion
Runtime variable expansion
This commit is contained in:
commit
07bee8cffe
|
@ -112,6 +112,7 @@ static struct cmd_handler handlers[] = {
|
||||||
{ "mouse_warping", cmd_mouse_warping },
|
{ "mouse_warping", cmd_mouse_warping },
|
||||||
{ "output", cmd_output },
|
{ "output", cmd_output },
|
||||||
{ "seat", cmd_seat },
|
{ "seat", cmd_seat },
|
||||||
|
{ "set", cmd_set },
|
||||||
{ "show_marks", cmd_show_marks },
|
{ "show_marks", cmd_show_marks },
|
||||||
{ "workspace", cmd_workspace },
|
{ "workspace", cmd_workspace },
|
||||||
{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
|
{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
|
||||||
|
@ -120,7 +121,6 @@ static struct cmd_handler handlers[] = {
|
||||||
/* Config-time only commands. Keep alphabetized */
|
/* Config-time only commands. Keep alphabetized */
|
||||||
static struct cmd_handler config_handlers[] = {
|
static struct cmd_handler config_handlers[] = {
|
||||||
{ "default_orientation", cmd_default_orientation },
|
{ "default_orientation", cmd_default_orientation },
|
||||||
{ "set", cmd_set },
|
|
||||||
{ "swaybg_command", cmd_swaybg_command },
|
{ "swaybg_command", cmd_swaybg_command },
|
||||||
{ "workspace_layout", cmd_workspace_layout },
|
{ "workspace_layout", cmd_workspace_layout },
|
||||||
};
|
};
|
||||||
|
@ -270,6 +270,13 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Var replacement, for all but first argument of set
|
||||||
|
for (int i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
|
||||||
|
argv[i] = do_var_replacement(argv[i]);
|
||||||
|
unescape_string(argv[i]);
|
||||||
|
strip_quotes(argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!config->handler_context.using_criteria) {
|
if (!config->handler_context.using_criteria) {
|
||||||
// without criteria, the command acts upon the focused
|
// without criteria, the command acts upon the focused
|
||||||
// container
|
// container
|
||||||
|
|
|
@ -657,6 +657,14 @@ char *do_var_replacement(char *str) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Unescape double $ and move on
|
||||||
|
if (find[1] == '$') {
|
||||||
|
size_t length = strlen(find + 1);
|
||||||
|
strncpy(find, find + 1, length);
|
||||||
|
find[length] = '\0';
|
||||||
|
++find;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Find matching variable
|
// Find matching variable
|
||||||
for (i = 0; i < config->symbols->length; ++i) {
|
for (i = 0; i < config->symbols->length; ++i) {
|
||||||
struct sway_variable *var = config->symbols->items[i];
|
struct sway_variable *var = config->symbols->items[i];
|
||||||
|
|
|
@ -128,12 +128,14 @@ char *workspace_next_name(const char *output_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("workspace", cmd) == 0 && name) {
|
if (strcmp("workspace", cmd) == 0 && name) {
|
||||||
wlr_log(L_DEBUG, "Got valid workspace command for target: '%s'", name);
|
|
||||||
char *_target = strdup(name);
|
char *_target = strdup(name);
|
||||||
|
_target = do_var_replacement(_target);
|
||||||
strip_quotes(_target);
|
strip_quotes(_target);
|
||||||
while (isspace(*_target)) {
|
while (isspace(*_target)) {
|
||||||
memmove(_target, _target+1, strlen(_target+1));
|
memmove(_target, _target+1, strlen(_target+1));
|
||||||
}
|
}
|
||||||
|
wlr_log(L_DEBUG, "Got valid workspace command for target: '%s'",
|
||||||
|
_target);
|
||||||
|
|
||||||
// Make sure that the command references an actual workspace
|
// Make sure that the command references an actual workspace
|
||||||
// not a command about workspaces
|
// not a command about workspaces
|
||||||
|
|
Loading…
Reference in a new issue