mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #207 from jonfin/tooltip-network
Add custom tooltip format for network module
This commit is contained in:
commit
584750d0fe
@ -135,10 +135,17 @@ void waybar::modules::Network::worker()
|
||||
auto waybar::modules::Network::update() -> void
|
||||
{
|
||||
std::string connectiontype;
|
||||
std::string tooltip_format = "";
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
if (ifid_ <= 0 || ipaddr_.empty()) {
|
||||
if (config_["format-disconnected"].isString()) {
|
||||
default_format_ = config_["format-disconnected"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-disconnected"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-disconnected"].asString();
|
||||
}
|
||||
label_.get_style_context()->add_class("disconnected");
|
||||
connectiontype = "disconnected";
|
||||
} else {
|
||||
@ -146,11 +153,17 @@ auto waybar::modules::Network::update() -> void
|
||||
if (config_["format-ethernet"].isString()) {
|
||||
default_format_ = config_["format-ethernet"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-ethernet"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-ethernet"].asString();
|
||||
}
|
||||
connectiontype = "ethernet";
|
||||
} else {
|
||||
if (config_["format-wifi"].isString()) {
|
||||
default_format_ = config_["format-wifi"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-wifi"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-wifi"].asString();
|
||||
}
|
||||
connectiontype = "wifi";
|
||||
}
|
||||
label_.get_style_context()->remove_class("disconnected");
|
||||
@ -158,7 +171,7 @@ auto waybar::modules::Network::update() -> void
|
||||
if (!alt_) {
|
||||
format_ = default_format_;
|
||||
}
|
||||
label_.set_markup(fmt::format(format_,
|
||||
auto text = fmt::format(format_,
|
||||
fmt::arg("essid", essid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||
fmt::arg("signalStrength", signal_strength_),
|
||||
@ -167,7 +180,25 @@ auto waybar::modules::Network::update() -> void
|
||||
fmt::arg("ipaddr", ipaddr_),
|
||||
fmt::arg("cidr", cidr_),
|
||||
fmt::arg("icon", getIcon(signal_strength_, connectiontype))
|
||||
));
|
||||
);
|
||||
label_.set_markup(text);
|
||||
if (tooltipEnabled()) {
|
||||
if (!tooltip_format.empty()) {
|
||||
auto tooltip_text = fmt::format(tooltip_format,
|
||||
fmt::arg("essid", essid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||
fmt::arg("signalStrength", signal_strength_),
|
||||
fmt::arg("ifname", ifname_),
|
||||
fmt::arg("netmask", netmask_),
|
||||
fmt::arg("ipaddr", ipaddr_),
|
||||
fmt::arg("cidr", cidr_),
|
||||
fmt::arg("icon", getIcon(signal_strength_, connectiontype))
|
||||
);
|
||||
label_.set_tooltip_text(tooltip_text);
|
||||
} else {
|
||||
label_.set_tooltip_text(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::Network::disconnected()
|
||||
|
Loading…
Reference in New Issue
Block a user