From 4fcf06a164e7c2daa4fb73762f010f16528f9960 Mon Sep 17 00:00:00 2001 From: Vesim Date: Tue, 18 Feb 2020 22:09:37 +0100 Subject: [PATCH 1/6] Add a way to exclude specific output --- src/client.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index f7c70e06..51f4a8a7 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -64,21 +64,31 @@ void waybar::Client::handleOutput(struct waybar_output &output) { } bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_output &output) { - bool found = true; + + auto check_output = [](std::string_view config_output_name, struct waybar_output &output) { + 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; + } + return false; + }; + 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; + if (output_conf.isString()) { + if(check_output(output_conf.asString(), output)) { + return true; + } } } - found = in_array; } - if (config["output"].isString() && config["output"].asString() != output.name) { - found = false; + if (config["output"].isString()) { + return check_output(config["output"].asString(), output); } - return found; + + return false; } struct waybar::waybar_output &waybar::Client::getOutput(void *addr) { From 3ff1f28533f547bc7d592dcffeebfa4ce800558f Mon Sep 17 00:00:00 2001 From: Vesim Date: Tue, 18 Feb 2020 22:15:16 +0100 Subject: [PATCH 2/6] Update man page --- man/waybar.5.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ++ From 9525663014d01dfd7e7bb926a796eaf7a79f15be Mon Sep 17 00:00:00 2001 From: Vesim Date: Tue, 18 Feb 2020 22:40:21 +0100 Subject: [PATCH 3/6] Update src/client.cpp Co-Authored-By: Alex --- src/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index 51f4a8a7..d7f4e94c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -77,7 +77,7 @@ bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_outp if (config["output"].isArray()) { for (auto const &output_conf : config["output"]) { - if (output_conf.isString()) { + if (output_conf.isString() && check_output(output_conf.asString(), output)) { if(check_output(output_conf.asString(), output)) { return true; } From bb88038c1720f07f5fdcce62995dacf7fa33819f Mon Sep 17 00:00:00 2001 From: Vesim Date: Thu, 27 Feb 2020 21:49:09 +0100 Subject: [PATCH 4/6] Dont exclude outputs in arrays --- src/client.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index d7f4e94c..ead23fb3 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -64,28 +64,22 @@ void waybar::Client::handleOutput(struct waybar_output &output) { } bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_output &output) { + if (config["output"].isArray()) { + for (auto const &output_conf : config["output"]) { + if (output_conf.isString() && output_conf.asString() == output.name) { + return true; + } + } + } - auto check_output = [](std::string_view config_output_name, struct waybar_output &output) { + 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; } - return false; - }; - - if (config["output"].isArray()) { - for (auto const &output_conf : config["output"]) { - if (output_conf.isString() && check_output(output_conf.asString(), output)) { - if(check_output(output_conf.asString(), output)) { - return true; - } - } - } - } - if (config["output"].isString()) { - return check_output(config["output"].asString(), output); } return false; From 1209022492ec9702f0cceb838cbf5f867522f303 Mon Sep 17 00:00:00 2001 From: Vesim Date: Fri, 28 Feb 2020 07:54:00 +0100 Subject: [PATCH 5/6] Return true when outputs are not specified --- src/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index ead23fb3..baa2e7bf 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -82,7 +82,7 @@ bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_outp } } - return false; + return true; } struct waybar::waybar_output &waybar::Client::getOutput(void *addr) { From 4a80874da9f258b8162029b9c78b984a984cc4e8 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 17 Apr 2020 23:41:32 +0200 Subject: [PATCH 6/6] Update client.cpp --- src/client.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index baa2e7bf..5e76b3ce 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -70,9 +70,8 @@ bool waybar::Client::isValidOutput(const Json::Value &config, struct waybar_outp return true; } } - } - - if (config["output"].isString()) { + 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) == "!") {