diff options
author | emersion <contact@emersion.fr> | 2019-01-17 11:13:10 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-17 11:13:10 +0100 |
commit | 000b31398510a44773ba5a248108c3e2ffa08ebf (patch) | |
tree | 8c87fd8fa3490162a7286bd55fd763b59160fcf3 /sway/config/output.c | |
parent | Fixes for small existing bugs. (diff) | |
download | sway-000b31398510a44773ba5a248108c3e2ffa08ebf.tar.gz sway-000b31398510a44773ba5a248108c3e2ffa08ebf.tar.zst sway-000b31398510a44773ba5a248108c3e2ffa08ebf.zip |
swaybg: use output names instead of output indexes
Diffstat (limited to 'sway/config/output.c')
-rw-r--r-- | sway/config/output.c | 21 |
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) { | |||
229 | terminate_swaybg(output->bg_pid); | 229 | terminate_swaybg(output->bg_pid); |
230 | } | 230 | } |
231 | if (oc && oc->background && config->swaybg_command) { | 231 | if (oc && oc->background && config->swaybg_command) { |
232 | wlr_log(WLR_DEBUG, "Setting background for output %d to %s", | 232 | wlr_log(WLR_DEBUG, "Setting background for output %s to %s", |
233 | output_i, oc->background); | 233 | wlr_output->name, oc->background); |
234 | 234 | ||
235 | size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s", | 235 | size_t len = snprintf(NULL, 0, "%s \"%s\" \"%s\" %s %s", |
236 | config->swaybg_command, output_i, oc->background, | 236 | config->swaybg_command, wlr_output->name, oc->background, |
237 | oc->background_option, | 237 | oc->background_option, |
238 | oc->background_fallback ? oc->background_fallback : ""); | 238 | oc->background_fallback ? oc->background_fallback : ""); |
239 | char *command = malloc(len + 1); | 239 | char *command = malloc(len + 1); |
240 | if (!command) { | 240 | if (!command) { |
241 | wlr_log(WLR_DEBUG, "Unable to allocate swaybg command"); | 241 | wlr_log(WLR_DEBUG, "Unable to allocate swaybg command"); |
242 | return; | 242 | return; |
243 | } | 243 | } |
244 | snprintf(command, len + 1, "%s %d \"%s\" %s %s", | 244 | snprintf(command, len + 1, "%s \"%s\" \"%s\" %s %s", |
245 | config->swaybg_command, output_i, oc->background, | 245 | config->swaybg_command, wlr_output->name, oc->background, |
246 | oc->background_option, | 246 | oc->background_option, |
247 | oc->background_fallback ? oc->background_fallback : ""); | 247 | oc->background_fallback ? oc->background_fallback : ""); |
248 | wlr_log(WLR_DEBUG, "-> %s", command); | 248 | wlr_log(WLR_DEBUG, "-> %s", command); |
249 | 249 | ||
250 | char *const cmd[] = { "sh", "-c", command, NULL }; | 250 | char *const cmd[] = { "sh", "-c", command, NULL }; |
251 | output->bg_pid = fork(); | 251 | output->bg_pid = fork(); |
252 | if (output->bg_pid == 0) { | 252 | if (output->bg_pid == 0) { |
253 | execvp(cmd[0], cmd); | 253 | execvp(cmd[0], cmd); |
254 | wlr_log_errno(WLR_ERROR, "Failed to execute swaybg"); | ||
254 | } else { | 255 | } else { |
255 | free(command); | 256 | free(command); |
256 | } | 257 | } |