aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-10-08 15:50:56 +0200
committerGitHub <noreply@github.com>2018-10-08 15:50:56 +0200
commit45f2cd0c73cb21bea6ae27bd396cd3721f3cd41a (patch)
tree8fdc0a2cf97e16d129c893841a32081903804a98
parent1c1fbd49db9a493af8101792ceede5f035724a6d (diff)
parentab3a397d58898045c3461bbdca8f48361ccfb8f4 (diff)
downloadsway-45f2cd0c73cb21bea6ae27bd396cd3721f3cd41a.zip
sway-45f2cd0c73cb21bea6ae27bd396cd3721f3cd41a.tar.gz
sway-45f2cd0c73cb21bea6ae27bd396cd3721f3cd41a.tar.bz2
Merge pull request #2793 from emersion/disable-swaybg
Allow swaybg to be disabled
-rw-r--r--sway/commands/bar/status_command.c2
-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
5 files changed, 27 insertions, 15 deletions
diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c
index 5ea2252..5b4fdc8 100644
--- a/sway/commands/bar/status_command.c
+++ b/sway/commands/bar/status_command.c
@@ -20,6 +20,8 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
config->current_bar->status_command = new_command;
wlr_log(WLR_DEBUG, "Feeding bar with status command: %s",
config->current_bar->status_command);
+ } else {
+ free(new_command);
}
if (config->active && !config->validating) {
diff --git a/sway/commands/swaybg_command.c b/sway/commands/swaybg_command.c
index 36f7fdc..b184b19 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) {
return error;
}
- if (config->swaybg_command) {
- free(config->swaybg_command);
+ free(config->swaybg_command);
+ config->swaybg_command = NULL;
+
+ char *new_command = join_args(argv, argc);
+ if (strcmp(new_command, "-") != 0) {
+ config->swaybg_command = new_command;
+ wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
+ config->swaybg_command);
+ } else {
+ free(new_command);
}
- config->swaybg_command = join_args(argv, argc);
- wlr_log(WLR_DEBUG, "Using custom swaybg command: %s",
- config->swaybg_command);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
diff --git a/sway/config.c b/sway/config.c
index 8f8ed43..7f29347 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -136,6 +136,7 @@ void free_config(struct sway_config *config) {
free(config->floating_scroll_left_cmd);
free(config->floating_scroll_right_cmd);
free(config->font);
+ free(config->swaybg_command);
free((char *)config->current_config_path);
free((char *)config->current_config);
free(config);
@@ -240,6 +241,8 @@ static void config_defaults(struct sway_config *config) {
if (!(config->active_bar_modifiers = create_list())) goto cleanup;
+ if (!(config->swaybg_command = strdup("swaybg"))) goto cleanup;
+
if (!(config->config_chain = create_list())) goto cleanup;
config->current_config_path = NULL;
config->current_config = NULL;
diff --git a/sway/config/output.c b/sway/config/output.c
index 6f337b6..2b04135 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) {
}
}
- if (oc && oc->background) {
- if (output->bg_pid != 0) {
- terminate_swaybg(output->bg_pid);
- }
-
+ if (output->bg_pid != 0) {
+ 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);
size_t len = snprintf(NULL, 0, "%s %d \"%s\" %s %s",
- config->swaybg_command ? config->swaybg_command : "swaybg",
- output_i, oc->background, oc->background_option,
+ config->swaybg_command, output_i, oc->background,
+ oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
char *command = malloc(len + 1);
if (!command) {
@@ -247,8 +246,8 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
return;
}
snprintf(command, len + 1, "%s %d \"%s\" %s %s",
- config->swaybg_command ? config->swaybg_command : "swaybg",
- output_i, oc->background, oc->background_option,
+ config->swaybg_command, output_i, oc->background,
+ oc->background_option,
oc->background_fallback ? oc->background_fallback : "");
wlr_log(WLR_DEBUG, "-> %s", command);
@@ -260,6 +259,7 @@ void apply_output_config(struct output_config *oc, struct sway_output *output) {
free(command);
}
}
+
if (oc) {
switch (oc->dpms_state) {
case DPMS_ON:
@@ -353,4 +353,3 @@ void create_default_output_configs(void) {
list_add(config->output_configs, oc);
}
}
-
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 3fda6ce..c7d20b1 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.
Executes custom background _command_. Default is _swaybg_. Refer to
*output* below for more information.
+ It can be disabled by setting the command to a single dash:
+ _swaybg\_command -_
+
*swaynag\_command* <command>
Executes custom command for _swaynag_. Default is _swaynag_. Additional
arguments may be appended to the end. This should only be used to either