mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Merge pull request #261 from christophgysin/exec
Call swaybg without invoking a shell
This commit is contained in:
commit
206606b32c
1 changed files with 14 additions and 9 deletions
|
@ -334,17 +334,22 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
|
sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
|
||||||
char *cmd = malloc(
|
|
||||||
strlen("swaybg ") +
|
size_t bufsize = 4;
|
||||||
(i >= 10 ? 2 : 1) +
|
char output_id[bufsize];
|
||||||
strlen(oc->background) + 3 +
|
snprintf(output_id, bufsize, "%d", i);
|
||||||
strlen(oc->background_option) + 3 +
|
output_id[bufsize-1] = 0;
|
||||||
1);
|
|
||||||
sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option);
|
char *const cmd[] = {
|
||||||
|
"swaybg",
|
||||||
|
output_id,
|
||||||
|
oc->background,
|
||||||
|
oc->background_option,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
|
execvp(cmd[0], cmd);
|
||||||
}
|
}
|
||||||
free(cmd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue