mirror of
https://github.com/swaywm/sway.git
synced 2026-03-03 01:41:03 -05:00
Merge fd7a9a9cb3 into e3c2412565
This commit is contained in:
commit
7b50df59d4
2 changed files with 40 additions and 8 deletions
|
|
@ -28,13 +28,22 @@ struct cmd_results *cmd_exec_validate(int argc, char **argv) {
|
||||||
struct cmd_results *cmd_exec_process(int argc, char **argv) {
|
struct cmd_results *cmd_exec_process(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
|
bool matched_container_id = false;
|
||||||
bool no_startup_id = false;
|
bool no_startup_id = false;
|
||||||
if (strcmp(argv[0], "--no-startup-id") == 0) {
|
int argv_counter = -1;
|
||||||
no_startup_id = true;
|
while (argc > 0 && has_prefix(*argv, "--")) {
|
||||||
--argc; ++argv;
|
if (strcmp(argv[0], "--matched-container-id") == 0) {
|
||||||
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
|
matched_container_id = true;
|
||||||
return error;
|
} else if (strcmp(argv[0], "--no-startup-id") == 0) {
|
||||||
|
no_startup_id = true;
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "Unrecognized argument '%s'", *argv);
|
||||||
}
|
}
|
||||||
|
--argc; ++argv; --argv_counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((error = checkarg(argc, argv[argv_counter], EXPECTED_AT_LEAST, 1))) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1 && (argv[0][0] == '\'' || argv[0][0] == '"')) {
|
if (argc == 1 && (argv[0][0] == '\'' || argv[0][0] == '"')) {
|
||||||
|
|
@ -61,6 +70,26 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (matched_container_id && config->handler_context.node != NULL) {
|
||||||
|
size_t con_id = config->handler_context.node->id;
|
||||||
|
int con_id_len = snprintf(NULL, 0, "%zu", con_id);
|
||||||
|
if (con_id_len < 0) {
|
||||||
|
sway_log(SWAY_ERROR, "Unable to determine buffer length for SWAY_EXEC_CON_ID");
|
||||||
|
goto no_con_id_export;
|
||||||
|
}
|
||||||
|
// accommodate \0
|
||||||
|
con_id_len++;
|
||||||
|
char* con_id_str = malloc(con_id_len);
|
||||||
|
if (!con_id_str) {
|
||||||
|
sway_log(SWAY_ERROR, "Unable to allocate buffer for SWAY_EXEC_CON_ID");
|
||||||
|
goto no_con_id_export;
|
||||||
|
}
|
||||||
|
snprintf(con_id_str, con_id_len, "%zu", con_id);
|
||||||
|
setenv("SWAY_EXEC_CON_ID", con_id_str, 1);
|
||||||
|
free(con_id_str);
|
||||||
|
}
|
||||||
|
no_con_id_export:
|
||||||
|
|
||||||
execlp("sh", "sh", "-c", cmd, (void*)NULL);
|
execlp("sh", "sh", "-c", cmd, (void*)NULL);
|
||||||
sway_log_errno(SWAY_ERROR, "execve failed");
|
sway_log_errno(SWAY_ERROR, "execve failed");
|
||||||
_exit(0); // Close child process
|
_exit(0); // Close child process
|
||||||
|
|
|
||||||
|
|
@ -703,10 +703,13 @@ The default colors are:
|
||||||
windows that are spawned in floating mode, not windows that become floating
|
windows that are spawned in floating mode, not windows that become floating
|
||||||
afterwards.
|
afterwards.
|
||||||
|
|
||||||
*exec* <shell command>
|
*exec* [--matched-container-id] [--no-startup-id] <shell command>
|
||||||
Executes _shell command_ with sh.
|
Executes _shell command_ with sh. The _--matched-container-id_ option
|
||||||
|
exports matched container if following a criteria match or the focused
|
||||||
|
node otherwise in SWAY_EXEC_CON_ID. The _--no_startup_id_ option prevents
|
||||||
|
exporting of DESKTOP_STARTUP_ID.
|
||||||
|
|
||||||
*exec_always* <shell command>
|
*exec_always* [--matched-container-id] [--no-startup-id] <shell command>
|
||||||
Like *exec*, but the shell command will be executed _again_ after *reload*.
|
Like *exec*, but the shell command will be executed _again_ after *reload*.
|
||||||
|
|
||||||
*floating_maximum_size* <width> x <height>
|
*floating_maximum_size* <width> x <height>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue