aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands/swaybg_command.c15
-rw-r--r--sway/config.c3
-rw-r--r--sway/config/output.c19
-rw-r--r--sway/sway.5.scd3
4 files changed, 25 insertions, 15 deletions
diff --git a/sway/commands/swaybg_command.c b/sway/commands/swaybg_command.c
index 36f7fdcd..b184b193 100644
--- a/sway/commands/swaybg_command.c
+++ b/sway/commands/swaybg_command.c
@@ -9,12 +9,17 @@ struct cmd_results *cmd_swaybg_command(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 11
12 if (config->swaybg_command) { 12 free(config->swaybg_command);
13 free(config->swaybg_command); 13 config->swaybg_command = NULL;
14
15 char *new_command = join_args(argv, argc);
16 if (strcmp(new_command, "-") != 0) {
17 config->swaybg_command = new_command;
18 wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
19 config->swaybg_command);
20 } else {
21 free(new_command);
14 } 22 }
15 config->swaybg_command = join_args(argv, argc);
16 wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
17 config->swaybg_command);
18 23
19 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
20} 25}
diff --git a/sway/config.c b/sway/config.c
index 8f8ed438..7f29347a 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -136,6 +136,7 @@ void free_config(struct sway_config *config) {
136 free(config->floating_scroll_left_cmd); 136 free(config->floating_scroll_left_cmd);
137 free(config->floating_scroll_right_cmd); 137 free(config->floating_scroll_right_cmd);
138 free(config->font); 138 free(config->font);
139 free(config->swaybg_command);
139 free((char *)config->current_config_path); 140 free((char *)config->current_config_path);
140 free((char *)config->current_config); 141 free((char *)config->current_config);
141 free(config); 142 free(config);
@@ -240,6 +241,8 @@ static void config_defaults(struct sway_config *config) {
240 241
241 if (!(config->active_bar_modifiers = create_list())) goto cleanup; 242 if (!(config->active_bar_modifiers = create_list())) goto cleanup;
242 243
244 if (!(config->swaybg_command = strdup("swaybg"))) goto cleanup;
245
243 if (!(config->config_chain = create_list())) goto cleanup; 246 if (!(config->config_chain = create_list())) goto cleanup;
244 config->current_config_path = NULL; 247 config->current_config_path = NULL;
245 config->current_config = NULL; 248 config->current_config = NULL;
diff --git a/sway/config/output.c b/sway/config/output.c
index 6f337b66..2b041353 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -229,17 +229,16 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
229 } 229 }
230 } 230 }
231 231
232 if (oc && oc->background) { 232 if (output->bg_pid != 0) {
233 if (output->bg_pid != 0) { 233 terminate_swaybg(output->bg_pid);
234 terminate_swaybg(output->bg_pid); 234 }
235 } 235 if (oc && oc->background && config->swaybg_command) {
236
237 wlr_log(WLR_DEBUG, "Setting background for output %d to %s", 236 wlr_log(WLR_DEBUG, "Setting background for output %d to %s",
238 output_i, oc->background); 237 output_i, oc->background);
239 238
240 size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s", 239 size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
241 config->swaybg_command ? config->swaybg_command : "swaybg", 240 config->swaybg_command, output_i, oc->background,
242 output_i, oc->background, oc->background_option, 241 oc->background_option,
243 oc->background_fallback ? oc->background_fallback : ""); 242 oc->background_fallback ? oc->background_fallback : "");
244 char *command = malloc(len + 1); 243 char *command = malloc(len + 1);
245 if (!command) { 244 if (!command) {
@@ -247,8 +246,8 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
247 return; 246 return;
248 } 247 }
249 snprintf(command, len + 1, "%s %d \"%s\" %s %s", 248 snprintf(command, len + 1, "%s %d \"%s\" %s %s",
250 config->swaybg_command ? config->swaybg_command : "swaybg", 249 config->swaybg_command, output_i, oc->background,
251 output_i, oc->background, oc->background_option, 250 oc->background_option,
252 oc->background_fallback ? oc->background_fallback : ""); 251 oc->background_fallback ? oc->background_fallback : "");
253 wlr_log(WLR_DEBUG, "-> %s", command); 252 wlr_log(WLR_DEBUG, "-> %s", command);
254 253
@@ -260,6 +259,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
260 free(command); 259 free(command);
261 } 260 }
262 } 261 }
262
263 if (oc) { 263 if (oc) {
264 switch (oc->dpms_state) { 264 switch (oc->dpms_state) {
265 case DPMS_ON: 265 case DPMS_ON:
@@ -353,4 +353,3 @@ void create_default_output_configs(void) {
353 list_add(config->output_configs, oc); 353 list_add(config->output_configs, oc);
354 } 354 }
355} 355}
356
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 3fda6cef..c7d20b17 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -71,6 +71,9 @@ The following commands may only be used in the configuration file.
71 Executes custom background _command_. Default is _swaybg_. Refer to 71 Executes custom background _command_. Default is _swaybg_. Refer to
72 *output* below for more information. 72 *output* below for more information.
73 73
74 It can be disabled by setting the command to a single dash:
75 _swaybg\_command -_
76
74*swaynag\_command* <command> 77*swaynag\_command* <command>
75 Executes custom command for _swaynag_. Default is _swaynag_. Additional 78 Executes custom command for _swaynag_. Default is _swaynag_. Additional
76 arguments may be appended to the end. This should only be used to either 79 arguments may be appended to the end. This should only be used to either