summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-11-25 18:59:35 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-11-25 18:59:35 -0500
commit206606b32cd6bd9c6d6d83ff02d49b1d3c7e0b18 (patch)
tree385bdd23c2dc7aa403c1234be48a7528f04bcb1a
parentMerge pull request #260 from christophgysin/scale (diff)
parentCall swaybg without invoking a shell (diff)
downloadsway-206606b32cd6bd9c6d6d83ff02d49b1d3c7e0b18.tar.gz
sway-206606b32cd6bd9c6d6d83ff02d49b1d3c7e0b18.tar.zst
sway-206606b32cd6bd9c6d6d83ff02d49b1d3c7e0b18.zip
Merge pull request #261 from christophgysin/exec
Call swaybg without invoking a shell
-rw-r--r--sway/config.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/sway/config.c b/sway/config.c
index 4955c94f..ba88a315 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -334,17 +334,22 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
334 } 334 }
335 335
336 sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background); 336 sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
337 char *cmd = malloc( 337
338 strlen("swaybg ") + 338 size_t bufsize = 4;
339 (i >= 10 ? 2 : 1) + 339 char output_id[bufsize];
340 strlen(oc->background) + 3 + 340 snprintf(output_id, bufsize, "%d", i);
341 strlen(oc->background_option) + 3 + 341 output_id[bufsize-1] = 0;
342 1); 342
343 sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option); 343 char *const cmd[] = {
344 "swaybg",
345 output_id,
346 oc->background,
347 oc->background_option,
348 NULL,
349 };
344 if (fork() == 0) { 350 if (fork() == 0) {
345 execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); 351 execvp(cmd[0], cmd);
346 } 352 }
347 free(cmd);
348 } 353 }
349} 354}
350 355