Merge pull request #2053 from paul-ri/exlude-in-array
This commit is contained in:
commit
473eb0982b
|
@ -29,4 +29,4 @@ jobs:
|
|||
- name: build
|
||||
run: ninja -C build
|
||||
- name: test
|
||||
run: meson test -C build --no-rebuild --verbose --suite waybar
|
||||
run: make test
|
||||
|
|
4
Makefile
4
Makefile
|
@ -19,5 +19,9 @@ run: build
|
|||
debug-run: build-debug
|
||||
./build/waybar --log-level debug
|
||||
|
||||
test:
|
||||
meson test -C build --no-rebuild --verbose --suite waybar
|
||||
.PHONY: test
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
|
|
@ -30,6 +30,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. Exclamation mark(*!*) can be used to exclude specific output.
|
||||
In an array, star '*\**' can be used at the end to accept all outputs, in case all previous entries are exclusions.
|
||||
|
||||
*position* ++
|
||||
typeof: string ++
|
||||
|
|
|
@ -124,10 +124,22 @@ bool isValidOutput(const Json::Value &config, const std::string &name,
|
|||
const std::string &identifier) {
|
||||
if (config["output"].isArray()) {
|
||||
for (auto const &output_conf : config["output"]) {
|
||||
if (output_conf.isString() &&
|
||||
(output_conf.asString() == name || output_conf.asString() == identifier)) {
|
||||
if (output_conf.isString()) {
|
||||
auto config_output = output_conf.asString();
|
||||
if (config_output.substr(0, 1) == "!") {
|
||||
if (config_output.substr(1) == name || config_output.substr(1) == identifier) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (config_output == name || config_output == identifier) {
|
||||
return true;
|
||||
}
|
||||
if (config_output.substr(0, 1) == "*") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (config["output"].isString()) {
|
||||
|
|
|
@ -31,7 +31,7 @@ TEST_CASE("Load config with multiple bars", "[config]") {
|
|||
|
||||
SECTION("select multiple configs #1") {
|
||||
auto data = conf.getOutputConfigs("DP-0", "Fake DisplayPort output #0");
|
||||
REQUIRE(data.size() == 3);
|
||||
REQUIRE(data.size() == 4);
|
||||
REQUIRE(data[0]["layer"].asString() == "bottom");
|
||||
REQUIRE(data[0]["height"].asInt() == 20);
|
||||
REQUIRE(data[1]["layer"].asString() == "top");
|
||||
|
@ -40,6 +40,7 @@ TEST_CASE("Load config with multiple bars", "[config]") {
|
|||
REQUIRE(data[2]["layer"].asString() == "overlay");
|
||||
REQUIRE(data[2]["position"].asString() == "right");
|
||||
REQUIRE(data[2]["height"].asInt() == 23);
|
||||
REQUIRE(data[3]["height"].asInt() == 24);
|
||||
}
|
||||
SECTION("select multiple configs #2") {
|
||||
auto data = conf.getOutputConfigs("HDMI-0", "Fake HDMI output #0");
|
||||
|
|
|
@ -21,5 +21,9 @@
|
|||
"layer": "overlay",
|
||||
"height": 23,
|
||||
"output": "!HDMI-1"
|
||||
},
|
||||
{
|
||||
"height": 24,
|
||||
"output": ["!HDMI-0", "!HDMI-1", "*"]
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue