diff --git a/src/ALabel.cpp b/src/ALabel.cpp index c7e794fa..87f93fab 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -40,11 +40,19 @@ auto waybar::ALabel::update() -> void { bool waybar::ALabel::handleToggle(GdkEventButton* const& e) { if (config_["on-click"].isString() && e->button == 1) { waybar::util::command::forkExec(config_["on-click"].asString()); + } else if (config_["on-click-middle"].isString() && e->button == 2) { + waybar::util::command::forkExec(config_["on-click-middle"].asString()); } else if (config_["on-click-right"].isString() && e->button == 3) { waybar::util::command::forkExec(config_["on-click-right"].asString()); - } else { + } else if (config_["on-click-forward"].isString() && e->button == 8) { + waybar::util::command::forkExec(config_["on-click-backward"].asString()); + } else if (config_["on-click-backward"].isString() && e->button == 9) { + waybar::util::command::forkExec(config_["on-click-forward"].asString()); + + + } else if (config_["format-alt-click"].isUInt() && e->button == config_["format-alt-click"].asUInt()) { alt_ = !alt_; - if (alt_) { + if (alt_ && config_["format-alt"].isString()) { format_ = config_["format-alt"].asString(); } else { format_ = default_format_; diff --git a/src/bar.cpp b/src/bar.cpp index f640ae8d..71540839 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -196,6 +196,54 @@ auto waybar::Bar::setupConfig() -> void std::istreambuf_iterator()); 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