config: fix validation exit code and log level

This makes it so invalid configs will return the exit code 1 when the
validation flag is given. This also reduces the log level to SWAY_ERROR,
which makes it so only the errors are shown. If someone wants more
verbose output, the can use the -V/--verbose or -d/--debug flags.
Additionally, this also makes it so swaybg will not be spawned when
validating the config.
master
Brian Ashworth 5 years ago committed by Simon Ser
parent 31a83bd48d
commit 33a984bbc5

@ -103,7 +103,7 @@ struct cmd_results *cmd_output(int argc, char **argv) {
// If reloading, the output configs will be applied after reading the // If reloading, the output configs will be applied after reading the
// entire config and before the deferred commands so that an auto generated // entire config and before the deferred commands so that an auto generated
// workspace name is not given to re-enabled outputs. // workspace name is not given to re-enabled outputs.
if (!config->reloading) { if (!config->reloading && !config->validating) {
apply_output_config_to_outputs(output); apply_output_config_to_outputs(output);
if (background) { if (background) {
spawn_swaybg(); spawn_swaybg();

@ -404,7 +404,7 @@ static bool load_config(const char *path, struct sway_config *config,
sway_log(SWAY_ERROR, "Error(s) loading config!"); sway_log(SWAY_ERROR, "Error(s) loading config!");
} }
return true; return config->active || !config->validating || config_load_success;
} }
bool load_main_config(const char *file, bool is_active, bool validating) { bool load_main_config(const char *file, bool is_active, bool validating) {

@ -315,7 +315,7 @@ int main(int argc, char **argv) {
if (debug) { if (debug) {
sway_log_init(SWAY_DEBUG, sway_terminate); sway_log_init(SWAY_DEBUG, sway_terminate);
wlr_log_init(WLR_DEBUG, NULL); wlr_log_init(WLR_DEBUG, NULL);
} else if (verbose || validate) { } else if (verbose) {
sway_log_init(SWAY_INFO, sway_terminate); sway_log_init(SWAY_INFO, sway_terminate);
wlr_log_init(WLR_INFO, NULL); wlr_log_init(WLR_INFO, NULL);
} else { } else {

Loading…
Cancel
Save