diff --git a/sway/commands/swaynag_command.c b/sway/commands/swaynag_command.c index c57a80a6..6c86f1a7 100644 --- a/sway/commands/swaynag_command.c +++ b/sway/commands/swaynag_command.c @@ -9,12 +9,17 @@ struct cmd_results *cmd_swaynag_command(int argc, char **argv) { return error; } - if (config->swaynag_command) { - free(config->swaynag_command); + free(config->swaynag_command); + config->swaynag_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 swaynag command: %s", + config->swaynag_command); + } else { + free(new_command); } - config->swaynag_command = join_args(argv, argc); - wlr_log(WLR_DEBUG, "Using custom swaynag command: %s", - config->swaynag_command); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/config.c b/sway/config.c index 7f29347a..e95c7b35 100644 --- a/sway/config.c +++ b/sway/config.c @@ -137,6 +137,7 @@ void free_config(struct sway_config *config) { free(config->floating_scroll_right_cmd); free(config->font); free(config->swaybg_command); + free(config->swaynag_command); free((char *)config->current_config_path); free((char *)config->current_config); free(config); @@ -167,7 +168,7 @@ static void set_color(float dest[static 4], uint32_t color) { } static void config_defaults(struct sway_config *config) { - config->swaynag_command = strdup("swaynag"); + if (!(config->swaynag_command = strdup("swaynag"))) goto cleanup; config->swaynag_config_errors = (struct swaynag_instance){ .args = "--type error " "--message 'There are errors in your config file' " diff --git a/sway/sway.5.scd b/sway/sway.5.scd index c7d20b17..43f0e132 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -81,6 +81,9 @@ The following commands may only be used in the configuration file. arguments. This should be placed at the top of the config for the best results. + It can be disabled by setting the command to a single dash: + _swaynag\_command -_ + The following commands cannot be used directly in the configuration file. They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). diff --git a/sway/swaynag.c b/sway/swaynag.c index d905db2b..38e74b88 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -11,6 +11,10 @@ bool swaynag_spawn(const char *swaynag_command, struct swaynag_instance *swaynag) { + if (!swaynag_command) { + return true; + } + if (swaynag->detailed) { if (pipe(swaynag->fd) != 0) { wlr_log(WLR_ERROR, "Failed to create pipe for swaynag"); @@ -58,6 +62,10 @@ void swaynag_kill(struct swaynag_instance *swaynag) { void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, const char *fmt, ...) { + if (!swaynag_command) { + return; + } + if (!swaynag->detailed) { wlr_log(WLR_ERROR, "Attempting to write to non-detailed swaynag inst"); return;