aboutsummaryrefslogtreecommitdiff
path: root/sway/config
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-03-29 17:49:44 -0400
committerDrew DeVault <sir@cmpwn.com>2018-03-29 22:11:08 -0400
commit5c9cdbcdd2a07e2ced7b60d629a3e20bd7c8bf68 (patch)
tree08a5de486cfceb091b5b1faa5e8ea893bea1de57 /sway/config
parent569b2bfd5daae5b3be49772bdca4a3f224e20629 (diff)
Add swaybg_command
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/output.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 24b4a18e..c3ec61b7 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -180,19 +180,20 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
wlr_log(L_DEBUG, "Setting background for output %d to %s",
output_i, oc->background);
- size_t bufsize = 12;
- char output_id[bufsize];
- snprintf(output_id, bufsize, "%d", output_i);
- output_id[bufsize-1] = 0;
-
- char *const cmd[] = {
- "swaybg",
- output_id,
- oc->background,
- oc->background_option,
- NULL,
- };
+ size_t len = snprintf(NULL, 0, "%s %d %s %s",
+ config->swaybg_command ? config->swaybg_command : "swaybg",
+ output_i, oc->background, oc->background_option);
+ char *command = malloc(len + 1);
+ if (!command) {
+ wlr_log(L_DEBUG, "Unable to allocate swaybg command");
+ return;
+ }
+ snprintf(command, len + 1, "%s %d %s %s",
+ config->swaybg_command ? config->swaybg_command : "swaybg",
+ output_i, oc->background, oc->background_option);
+ wlr_log(L_DEBUG, "-> %s", command);
+ char *const cmd[] = { "sh", "-c", command, NULL };
output->sway_output->bg_pid = fork();
if (output->sway_output->bg_pid == 0) {
execvp(cmd[0], cmd);