From fe3f4882edf81d4e72f77948a99cfa94af7998f8 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 17 Jan 2019 11:20:08 +0100 Subject: Don't use sh when spawning swaybg --- sway/config/output.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'sway/config') diff --git a/sway/config/output.c b/sway/config/output.c index 2cbfa3cd..f23d316d 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -232,28 +232,21 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) { wlr_log(WLR_DEBUG, "Setting background for output %s to %s", wlr_output->name, oc->background); - size_t len = snprintf(NULL, 0, "%s \"%s\" \"%s\" %s %s", - config->swaybg_command, wlr_output->name, oc->background, + char *const cmd[] = { + config->swaybg_command, + wlr_output->name, + oc->background, oc->background_option, - oc->background_fallback ? oc->background_fallback : ""); - char *command = malloc(len + 1); - if (!command) { - wlr_log(WLR_DEBUG, "Unable to allocate swaybg command"); - return; - } - snprintf(command, len + 1, "%s \"%s\" \"%s\" %s %s", - config->swaybg_command, wlr_output->name, oc->background, - oc->background_option, - oc->background_fallback ? oc->background_fallback : ""); - wlr_log(WLR_DEBUG, "-> %s", command); + oc->background_fallback ? oc->background_fallback : NULL, + NULL, + }; - char *const cmd[] = { "sh", "-c", command, NULL }; output->bg_pid = fork(); - if (output->bg_pid == 0) { + if (output->bg_pid < 0) { + wlr_log_errno(WLR_ERROR, "fork failed"); + } else if (output->bg_pid == 0) { execvp(cmd[0], cmd); wlr_log_errno(WLR_ERROR, "Failed to execute swaybg"); - } else { - free(command); } } -- cgit v1.2.3-54-g00ecf