aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-01-17 11:13:10 +0100
committeremersion <contact@emersion.fr>2019-01-17 11:13:10 +0100
commit000b31398510a44773ba5a248108c3e2ffa08ebf (patch)
tree8c87fd8fa3490162a7286bd55fd763b59160fcf3 /sway
parent70637b40fe98bda420e279e2e059fc93a9f538d6 (diff)
swaybg: use output names instead of output indexes
Diffstat (limited to 'sway')
-rw-r--r--sway/config/output.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index f24e7d66..2cbfa3cd 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -229,28 +229,29 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
terminate_swaybg(output->bg_pid);
}
if (oc && oc->background && config->swaybg_command) {
- wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
- output_i, oc->background);
+ wlr_log(WLR_DEBUG, "Setting background for output %s to %s",
+ wlr_output->name, oc->background);
- size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
- config->swaybg_command, output_i, oc->background,
- oc->background_option,
- oc->background_fallback ? oc->background_fallback : "");
+ size_t len = snprintf(NULL, 0, "%s \"%s\" \"%s\" %s %s",
+ 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 %d \"%s\" %s %s",
- config->swaybg_command, output_i, oc->background,
- oc->background_option,
- oc->background_fallback ? oc->background_fallback : "");
+ 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);
char *const cmd[] = { "sh", "-c", command, NULL };
output->bg_pid = fork();
if (output->bg_pid == 0) {
execvp(cmd[0], cmd);
+ wlr_log_errno(WLR_ERROR, "Failed to execute swaybg");
} else {
free(command);
}