From 7404f80122f1c3453ec7425e6551006a65c9757a Mon Sep 17 00:00:00 2001 From: Robinhuett <5955614+Robinhuett@users.noreply.github.com> Date: Tue, 25 Dec 2018 14:15:59 +0100 Subject: [PATCH 1/3] fix(ALabel): getIcon --- src/ALabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 0a1c2b5b..7b26ef96 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -90,7 +90,7 @@ std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& alt) { auto format_icons = config_["format-icons"]; if (format_icons.isObject()) { - if (!alt.empty() && format_icons[alt].isString()) { + if (!alt.empty() && format_icons[alt].isArray()) { format_icons = format_icons[alt]; } else { format_icons = format_icons["default"]; From ad638357b5fb0387c2e8a5163306a6b6d0b32470 Mon Sep 17 00:00:00 2001 From: Robinhuett <5955614+Robinhuett@users.noreply.github.com> Date: Tue, 25 Dec 2018 14:17:34 +0100 Subject: [PATCH 2/3] feat(network): Use Signal Strength for format-icons --- src/modules/network.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 4fd59cb9..ef68cb6a 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -105,17 +105,21 @@ 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; label_.get_style_context()->add_class("disconnected"); + connectiontype = "disconnected"; } else { if (essid_.empty()) { format = config_["format-ethernet"].isString() ? config_["format-ethernet"].asString() : format; + connectiontype = "ethernet"; } else { format = config_["format-wifi"].isString() ? config_["format-wifi"].asString() : format; + connectiontype = "wifi"; } label_.get_style_context()->remove_class("disconnected"); } @@ -126,7 +130,8 @@ auto waybar::modules::Network::update() -> void fmt::arg("ifname", ifname_), fmt::arg("netmask", netmask_), fmt::arg("ipaddr", ipaddr_), - fmt::arg("cidr", cidr_) + fmt::arg("cidr", cidr_), + fmt::arg("icon", getIcon(signal_strength_, connectiontype)) )); } From 34df2b06951f27d7dc86a55e2fc61080f49c7d57 Mon Sep 17 00:00:00 2001 From: Robinhuett <5955614+Robinhuett@users.noreply.github.com> Date: Tue, 25 Dec 2018 21:03:13 +0100 Subject: [PATCH 3/3] fix(ALabel): Better fix for getIcon --- src/ALabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ALabel.cpp b/src/ALabel.cpp index 7b26ef96..668d143b 100644 --- a/src/ALabel.cpp +++ b/src/ALabel.cpp @@ -90,7 +90,7 @@ std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& alt) { auto format_icons = config_["format-icons"]; if (format_icons.isObject()) { - if (!alt.empty() && format_icons[alt].isArray()) { + if (!alt.empty() && (format_icons[alt].isString() || format_icons[alt].isArray())) { format_icons = format_icons[alt]; } else { format_icons = format_icons["default"];