launcher: export X startup ids and use them for workspace matching

This commit is contained in:
Ronan Pigott 2022-11-16 15:50:34 -07:00 committed by Simon Ser
parent 30ad4dc4a5
commit 28fda4c0d3
3 changed files with 43 additions and 1 deletions

View file

@ -32,11 +32,17 @@ static void export_xdga_token(struct launcher_ctx *ctx) {
setenv("XDG_ACTIVATION_TOKEN", token, 1);
}
static void export_startup_id(struct launcher_ctx *ctx) {
const char *token = launcher_ctx_get_token_name(ctx);
setenv("DESKTOP_STARTUP_ID", token, 1);
}
struct cmd_results *cmd_exec_process(int argc, char **argv) {
struct cmd_results *error = NULL;
char *cmd = NULL;
bool no_startup_id = false;
if (strcmp(argv[0], "--no-startup-id") == 0) {
sway_log(SWAY_INFO, "exec switch '--no-startup-id' not supported, ignored.");
no_startup_id = true;
--argc; ++argv;
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
return error;
@ -74,6 +80,9 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) {
if (ctx) {
export_xdga_token(ctx);
}
if (ctx && !no_startup_id) {
export_startup_id(ctx);
}
execlp("sh", "sh", "-c", cmd, (void *)NULL);
sway_log_errno(SWAY_ERROR, "execlp failed");
_exit(1);