fix: config per output
This commit is contained in:
parent
973cec1713
commit
2995da845d
95
src/bar.cpp
95
src/bar.cpp
|
@ -37,6 +37,53 @@ waybar::Bar::Bar(const Client& client,
|
|||
|
||||
void waybar::Bar::initBar()
|
||||
{
|
||||
// Converting string to button code rn as to avoid doing it later
|
||||
auto setupAltFormatKeyForModule = [this](const std::string& module_name){
|
||||
if (config_.isMember(module_name)) {
|
||||
Json::Value& module = config_[module_name];
|
||||
if (module.isMember("format-alt")) {
|
||||
if (module.isMember("format-alt-click")) {
|
||||
Json::Value& click = module["format-alt-click"];
|
||||
if (click.isString()) {
|
||||
std::string str_click = click.asString();
|
||||
|
||||
if (str_click == "click-right") {
|
||||
module["format-alt-click"] = 3u;
|
||||
} else if (str_click == "click-middle") {
|
||||
module["format-alt-click"] = 2u;
|
||||
} else if (str_click == "click-backward") {
|
||||
module["format-alt-click"] = 8u;
|
||||
} else if (str_click == "click-forward") {
|
||||
module["format-alt-click"] = 9u;
|
||||
} else {
|
||||
module["format-alt-click"] = 1u; // default click-left
|
||||
}
|
||||
} else {
|
||||
module["format-alt-click"] = 1u;
|
||||
}
|
||||
} else {
|
||||
module["format-alt-click"] = 1u;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto setupAltFormatKeyForModuleList = [this, &setupAltFormatKeyForModule](const char* module_list_name) {
|
||||
if (config_.isMember(module_list_name)) {
|
||||
Json::Value& modules = config_[module_list_name];
|
||||
for (const Json::Value& module_name : modules) {
|
||||
if (module_name.isString()) {
|
||||
setupAltFormatKeyForModule(module_name.asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Convert to button code for every module that is used.
|
||||
setupAltFormatKeyForModuleList("modules-left");
|
||||
setupAltFormatKeyForModuleList("modules-right");
|
||||
setupAltFormatKeyForModuleList("modules-center");
|
||||
std::size_t layer_top = config_["layer"] == "top"
|
||||
? ZWLR_LAYER_SHELL_V1_LAYER_TOP : ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
|
@ -196,54 +243,6 @@ auto waybar::Bar::setupConfig() -> void
|
|||
std::istreambuf_iterator<char>());
|
||||
util::JsonParser parser;
|
||||
config_ = parser.parse(str);
|
||||
|
||||
// Converting string to button code rn as to avoid doing it later
|
||||
auto setupAltFormatKeyForModule = [this](const std::string& module_name){
|
||||
if (config_.isMember(module_name)) {
|
||||
Json::Value& module = config_[module_name];
|
||||
if (module.isMember("format-alt")) {
|
||||
if (module.isMember("format-alt-click")) {
|
||||
Json::Value& click = module["format-alt-click"];
|
||||
if (click.isString()) {
|
||||
std::string str_click = click.asString();
|
||||
|
||||
if (str_click == "click-right") {
|
||||
module["format-alt-click"] = 3u;
|
||||
} else if (str_click == "click-middle") {
|
||||
module["format-alt-click"] = 2u;
|
||||
} else if (str_click == "click-backward") {
|
||||
module["format-alt-click"] = 8u;
|
||||
} else if (str_click == "click-forward") {
|
||||
module["format-alt-click"] = 9u;
|
||||
} else {
|
||||
module["format-alt-click"] = 1u; // default click-left
|
||||
}
|
||||
} else {
|
||||
module["format-alt-click"] = 1u;
|
||||
}
|
||||
} else {
|
||||
module["format-alt-click"] = 1u;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto setupAltFormatKeyForModuleList = [this, &setupAltFormatKeyForModule](const char* module_list_name) {
|
||||
if (config_.isMember(module_list_name)) {
|
||||
Json::Value& modules = config_[module_list_name];
|
||||
for (const Json::Value& module_name : modules) {
|
||||
if (module_name.isString()) {
|
||||
setupAltFormatKeyForModule(module_name.asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Convert to button code for every module that is used.
|
||||
setupAltFormatKeyForModuleList("modules-left");
|
||||
setupAltFormatKeyForModuleList("modules-right");
|
||||
setupAltFormatKeyForModuleList("modules-center");
|
||||
}
|
||||
|
||||
auto waybar::Bar::setupCss() -> void
|
||||
|
|
Loading…
Reference in New Issue