From 5728307520fe80b34067cf4d312409548d4a0a10 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 19 Nov 2015 18:55:17 -0500 Subject: Add wallpapers to output command --- sway/config.c | 22 ++++++++++++++++++++++ sway/handlers.c | 5 +++++ 2 files changed, 27 insertions(+) (limited to 'sway') diff --git a/sway/config.c b/sway/config.c index ce6d8baf..2c9cc290 100644 --- a/sway/config.c +++ b/sway/config.c @@ -314,6 +314,28 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { } output->x = x; } + + if (oc->background) { + int i; + for (i = 0; i < root_container.children->length; ++i) { + if (root_container.children->items[i] == output) { + break; + } + } + + 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); + if (fork() == 0) { + execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); + } + free(cmd); + } } char *do_var_replacement(char *str) { diff --git a/sway/handlers.c b/sway/handlers.c index dde9b88b..28fa9564 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -43,6 +43,11 @@ static bool handle_output_created(wlc_handle output) { swayc_t *ws = op->children->items[0]; workspace_switch(ws); } + + // Fixes issues with backgrounds and wlc + wlc_handle prev = wlc_get_focused_output(); + wlc_output_focus(output); + wlc_output_focus(prev); return true; } -- cgit v1.2.3-54-g00ecf