fix(Network): format-alt
parent
f8116132a7
commit
eace8c549f
|
@ -23,12 +23,12 @@ protected:
|
|||
std::string format_;
|
||||
std::mutex mutex_;
|
||||
const std::chrono::seconds interval_;
|
||||
bool alt_ = false;
|
||||
std::string default_format_;
|
||||
|
||||
private:
|
||||
bool handleToggle(GdkEventButton *const &ev);
|
||||
bool handleScroll(GdkEventScroll *);
|
||||
bool alt = false;
|
||||
const std::string default_format_;
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
|
|
@ -43,8 +43,8 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
|
|||
} else if (config_["on-click-right"].isString() && e->button == 3) {
|
||||
waybar::util::command::forkExec(config_["on-click-right"].asString());
|
||||
} else {
|
||||
alt = !alt;
|
||||
if (alt) {
|
||||
alt_ = !alt_;
|
||||
if (alt_) {
|
||||
format_ = config_["format-alt"].asString();
|
||||
} else {
|
||||
format_ = default_format_;
|
||||
|
|
|
@ -135,26 +135,31 @@ void waybar::modules::Network::worker()
|
|||
|
||||
auto waybar::modules::Network::update() -> void
|
||||
{
|
||||
auto format = format_;
|
||||
std::string connectiontype;
|
||||
if (ifid_ <= 0 || ipaddr_.empty()) {
|
||||
format = config_["format-disconnected"].isString()
|
||||
? config_["format-disconnected"].asString() : format;
|
||||
if (config_["format-disconnected"].isString()) {
|
||||
default_format_ = config_["format-disconnected"].asString();
|
||||
}
|
||||
label_.get_style_context()->add_class("disconnected");
|
||||
connectiontype = "disconnected";
|
||||
} else {
|
||||
if (essid_.empty()) {
|
||||
format = config_["format-ethernet"].isString()
|
||||
? config_["format-ethernet"].asString() : format;
|
||||
if (config_["format-ethernet"].isString()) {
|
||||
default_format_ = config_["format-ethernet"].asString();
|
||||
}
|
||||
connectiontype = "ethernet";
|
||||
} else {
|
||||
format = config_["format-wifi"].isString()
|
||||
? config_["format-wifi"].asString() : format;
|
||||
if (config_["format-wifi"].isString()) {
|
||||
default_format_ = config_["format-wifi"].asString();
|
||||
}
|
||||
connectiontype = "wifi";
|
||||
}
|
||||
label_.get_style_context()->remove_class("disconnected");
|
||||
}
|
||||
label_.set_markup(fmt::format(format,
|
||||
if (!alt_) {
|
||||
format_ = default_format_;
|
||||
}
|
||||
label_.set_markup(fmt::format(format_,
|
||||
fmt::arg("essid", essid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||
fmt::arg("signalStrength", signal_strength_),
|
||||
|
|
Loading…
Reference in New Issue