aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-11-25 18:59:35 -0500
committerDrew DeVault <sir@cmpwn.com>2015-11-25 18:59:35 -0500
commit206606b32cd6bd9c6d6d83ff02d49b1d3c7e0b18 (patch)
tree385bdd23c2dc7aa403c1234be48a7528f04bcb1a /sway
parenta713686daa0b80bb7273a220d08ad99bcf1dab72 (diff)
parente362f871d93df7568267d9a50ff77b63f5300528 (diff)
Merge pull request #261 from christophgysin/exec
Call swaybg without invoking a shell
Diffstat (limited to 'sway')
-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) {
}
sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
- char *cmd = malloc(
- strlen("swaybg ") +
- (i >= 10 ? 2 : 1) +
- strlen(oc->background) + 3 +
- strlen(oc->background_option) + 3 +
- 1);
- sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option);
+
+ size_t bufsize = 4;
+ char output_id[bufsize];
+ snprintf(output_id, bufsize, "%d", i);
+ output_id[bufsize-1] = 0;
+
+ char *const cmd[] = {
+ "swaybg",
+ output_id,
+ oc->background,
+ oc->background_option,
+ NULL,
+ };
if (fork() == 0) {
- execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
+ execvp(cmd[0], cmd);
}
- free(cmd);
}
}