diff --git a/man/waybar.5.scd b/man/waybar.5.scd index 758d90a9..3981cb58 100644 --- a/man/waybar.5.scd +++ b/man/waybar.5.scd @@ -28,7 +28,7 @@ Also a minimal example configuration can be found on the at the bottom of this m *output* ++ typeof: string|array ++ - Specifies on which screen this bar will be displayed. + Specifies on which screen this bar will be displayed. Exclamation mark(*!*) can be used to exclude specific output. *position* ++ typeof: string ++ diff --git a/src/client.cpp b/src/client.cpp index f7c70e06..5e76b3ce 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -64,21 +64,24 @@ void waybar::Client::handleOutput(struct waybar_output &output) { } bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_output &output) { - bool found = true; if (config["output"].isArray()) { - bool in_array = false; for (auto const &output_conf : config["output"]) { if (output_conf.isString() && output_conf.asString() == output.name) { - in_array = true; - break; + return true; } } - found = in_array; + return false; + } else if (config["output"].isString()) { + auto config_output_name = config["output"].asString(); + if (!config_output_name.empty()) { + if (config_output_name.substr(0, 1) == "!") { + return config_output_name.substr(1) != output.name; + } + return config_output_name == output.name; + } } - if (config["output"].isString() && config["output"].asString() != output.name) { - found = false; - } - return found; + + return true; } struct waybar::waybar_output &waybar::Client::getOutput(void *addr) {