From 794fb12e8c54c9a1e1f921dac7520c59dc048dba Mon Sep 17 00:00:00 2001 From: Lucas Lazare Date: Fri, 17 May 2019 23:39:51 -0400 Subject: [PATCH 01/10] Adding bandwidth support for network module [linux only] --- include/modules/network.hpp | 3 + src/modules/network.cpp | 127 +++++++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/include/modules/network.hpp b/include/modules/network.hpp index 3afae571..44c9781d 100644 --- a/include/modules/network.hpp +++ b/include/modules/network.hpp @@ -56,6 +56,9 @@ class Network : public ALabel { int nl80211_id_; std::mutex mutex_; + unsigned long long bandwidth_down_total_; + unsigned long long bandwidth_up_total_; + std::string essid_; std::string ifname_; std::string ipaddr_; diff --git a/src/modules/network.cpp b/src/modules/network.cpp index cca1d50b..baa546da 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -1,5 +1,70 @@ #include "modules/network.hpp" #include +#include + +namespace { + + constexpr const char * NETSTAT_FILE = "/proc/net/netstat"; // std::ifstream does not take std::string_view as param + constexpr std::string_view BANDWIDTH_CATEGORY = "IpExt"; + constexpr std::string_view BANDWIDTH_DOWN_TOTAL_KEY = "InOctets"; + constexpr std::string_view BANDWIDTH_UP_TOTAL_KEY = "OutOctets"; + + std::ifstream netstat(NETSTAT_FILE); + std::optional read_netstat(std::string_view category, std::string_view key) { + if (!netstat) { + return {}; + } + netstat.seekg(std::ios_base::beg); + + + // finding corresponding line (category) + // looks into the file for the first line starting by the 'category' string + auto starts_with = [](const std::string& str, std::string_view start) { + return start == std::string_view{str.data(), std::min(str.size(), start.size())}; + }; + + std::string read; + while (std::getline(netstat, read) && !starts_with(read, category)); + if (!starts_with(read, category)) { + return {}; + } + + // finding corresponding column (key) + // looks into the fetched line for the first word (space separated) equal to 'key' + int index = 0; + auto r_it = read.begin(); + auto k_it = key.begin(); + while (k_it != key.end() && r_it != read.end()) { + if (*r_it != *k_it) { + r_it = std::find(r_it, read.end(), ' '); + if (r_it != read.end()) { + ++r_it; + } + k_it = key.begin(); + ++index; + } else { + ++r_it; + ++k_it; + } + } + + if (r_it == read.end() && k_it != key.end()) { + return {}; + } + + // finally accessing value + // accesses the line right under the fetched one + std::getline(netstat, read); + assert(starts_with(read, category)); + std::istringstream iss(read); + while (index--) { + std::getline(iss, read, ' '); + } + unsigned long long value; + iss >> value; + return value; + } +} waybar::modules::Network::Network(const std::string &id, const Json::Value &config) : ALabel(config, "{ifname}", 60), @@ -16,6 +81,21 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf if (!id.empty()) { label_.get_style_context()->add_class(id); } + + auto down_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_DOWN_TOTAL_KEY); + auto up_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_UP_TOTAL_KEY); + if (down_octets) { + bandwidth_down_total_ = *down_octets; + } else { + bandwidth_down_total_ = 0; + } + + if (up_octets) { + bandwidth_up_total_ = *up_octets; + } else { + bandwidth_up_total_ = 0; + } + createInfoSocket(); createEventSocket(); auto default_iface = getPreferredIface(); @@ -131,6 +211,22 @@ void waybar::modules::Network::worker() { } auto waybar::modules::Network::update() -> void { + auto down_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_DOWN_TOTAL_KEY); + auto up_octets = read_netstat(BANDWIDTH_CATEGORY, BANDWIDTH_UP_TOTAL_KEY); + + unsigned long long bandwidth_down = 0; + if (down_octets) { + bandwidth_down = *down_octets - bandwidth_down_total_; + bandwidth_down_total_ = *down_octets; + } + + unsigned long long bandwidth_up = 0; + if (up_octets) { + bandwidth_up = *up_octets - bandwidth_up_total_; + bandwidth_up_total_ = *up_octets; + } + + std::string connectiontype; std::string tooltip_format = ""; if (config_["tooltip-format"].isString()) { @@ -177,6 +273,25 @@ auto waybar::modules::Network::update() -> void { format_ = default_format_; } getState(signal_strength_); + + auto pow_format = [](unsigned long long value, const std::string& unit) { + if (value > 2000ull * 1000ull * 1000ull) { // > 2G + auto go = value / (1000 * 1000 * 1000); + return std::to_string(go) + "." + std::to_string((value - go * 1000 * 1000 * 1000) / (100 * 1000 * 1000)) + "G" + unit; + + } else if (value > 2000ull * 1000ull) { // > 2M + auto mo = value / (1000 * 1000); + return std::to_string(mo) + "." + std::to_string((value - mo * 1000 * 1000) / (100 * 1000)) + "M" + unit; + + } else if (value > 2000ull) { // > 2k + auto ko = value / 1000; + return std::to_string(ko) + "." + std::to_string((value - ko * 1000) / 100) + "k" + unit; + + } else { + return std::to_string(value) + unit; + } + }; + auto text = fmt::format(format_, fmt::arg("essid", essid_), fmt::arg("signaldBm", signal_strength_dbm_), @@ -186,7 +301,11 @@ auto waybar::modules::Network::update() -> void { fmt::arg("ipaddr", ipaddr_), fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), - fmt::arg("icon", getIcon(signal_strength_, connectiontype))); + fmt::arg("icon", getIcon(signal_strength_, connectiontype)), + fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull, "b")), + fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull, "b")), + fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down, "o")), + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up, "o"))); label_.set_markup(text); if (tooltipEnabled()) { if (!tooltip_format.empty()) { @@ -199,7 +318,11 @@ auto waybar::modules::Network::update() -> void { fmt::arg("ipaddr", ipaddr_), fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), - fmt::arg("icon", getIcon(signal_strength_, connectiontype))); + fmt::arg("icon", getIcon(signal_strength_, connectiontype)), + fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull, "b")), + fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull, "b")), + fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down, "o")), + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up, "o"))); label_.set_tooltip_text(tooltip_text); } else { label_.set_tooltip_text(text); From d34c3a801c3ab73eb70b02dc0bea25b4ae1bb81d Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 12:27:10 +0200 Subject: [PATCH 02/10] fix(Network): less updates --- src/modules/network.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index cca1d50b..586cca24 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -25,7 +25,6 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf ifname_ = ifname; getInterfaceAddress(); } - dp.emit(); worker(); } @@ -461,14 +460,12 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { net->linked_ = true; net->ifname_ = ifname; net->ifid_ = rtif->ifi_index; - net->dp.emit(); } // Check for valid interface if (rtif->ifi_index == static_cast(net->ifid_)) { // Get Iface and WIFI info - net->thread_timer_.wake_up(); net->getInterfaceAddress(); - net->dp.emit(); + net->thread_timer_.wake_up(); } } else if (nh->nlmsg_type == RTM_DELADDR) { auto rtif = static_cast(NLMSG_DATA(nh)); @@ -499,10 +496,11 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { // Check for a new interface and get info auto new_iface = net->getPreferredIface(); if (new_iface != -1) { - net->thread_timer_.wake_up(); net->getInterfaceAddress(); + net->thread_timer_.wake_up(); + } else { + net->dp.emit(); } - net->dp.emit(); } } return NL_SKIP; From 3e1c77d1588b8c72e6f2203f16af9f927dd7a3d0 Mon Sep 17 00:00:00 2001 From: RX14 Date: Fri, 17 May 2019 17:53:38 +0100 Subject: [PATCH 03/10] Add option to disable scroll wraparound on workspaces --- src/modules/sway/workspaces.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index a623b411..231b3363 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -215,7 +215,7 @@ bool Workspaces::handleScroll(GdkEventScroll *e) { const std::string Workspaces::getCycleWorkspace(std::vector::iterator it, bool prev) const { - if (prev && it == workspaces_.begin()) { + if (prev && it == workspaces_.begin() && !config_["disable-scroll-wraparound"].asBool()) { return (*(--workspaces_.end()))["name"].asString(); } if (prev && it != workspaces_.begin()) @@ -223,7 +223,11 @@ const std::string Workspaces::getCycleWorkspace(std::vector::iterat else if (!prev && it != workspaces_.end()) ++it; if (!prev && it == workspaces_.end()) { - return (*(workspaces_.begin()))["name"].asString(); + if (config_["disable-scroll-wraparound"].asBool()) { + --it; + } else { + return (*(workspaces_.begin()))["name"].asString(); + } } return (*it)["name"].asString(); } From 4865a9ad6c89a8a3e0e5b478d7ea2a4ba5f3d42e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 13:57:35 +0200 Subject: [PATCH 04/10] fix(network): reset frequency --- include/modules/network.hpp | 2 +- src/modules/network.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/modules/network.hpp b/include/modules/network.hpp index 3afae571..77438a36 100644 --- a/include/modules/network.hpp +++ b/include/modules/network.hpp @@ -38,7 +38,7 @@ class Network : public ALabel { void parseSignal(struct nlattr**); void parseFreq(struct nlattr**); bool associatedOrJoined(struct nlattr**); - bool checkInterface(int if_index, std::string name); + bool checkInterface(struct ifinfomsg *rtif, std::string name); int getPreferredIface(); auto getInfo() -> void; bool wildcardMatch(const std::string& pattern, const std::string& text); diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 586cca24..17795960 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -25,6 +25,7 @@ waybar::modules::Network::Network(const std::string &id, const Json::Value &conf ifname_ = ifname; getInterfaceAddress(); } + dp.emit(); worker(); } @@ -131,7 +132,7 @@ void waybar::modules::Network::worker() { auto waybar::modules::Network::update() -> void { std::string connectiontype; - std::string tooltip_format = ""; + std::string tooltip_format; if (config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); } @@ -198,7 +199,8 @@ auto waybar::modules::Network::update() -> void { fmt::arg("ipaddr", ipaddr_), fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), - fmt::arg("icon", getIcon(signal_strength_, connectiontype))); + fmt::arg("icon", getIcon(signal_strength_, + connectiontype))); label_.set_tooltip_text(tooltip_text); } else { label_.set_tooltip_text(text); @@ -397,7 +399,7 @@ int waybar::modules::Network::netlinkResponse(void *resp, uint32_t resplen, uint return ret; } -bool waybar::modules::Network::checkInterface(int if_index, std::string name) { +bool waybar::modules::Network::checkInterface(struct ifinfomsg *rtif, std::string name) { if (config_["interface"].isString()) { return config_["interface"].asString() == name || wildcardMatch(config_["interface"].asString(), name); @@ -405,9 +407,9 @@ bool waybar::modules::Network::checkInterface(int if_index, std::string name) { auto external_iface = getExternalInterface(); if (external_iface == -1) { // Try with lastest working external iface - return last_ext_iface_ == if_index; + return last_ext_iface_ == rtif->ifi_index; } - return external_iface == if_index; + return external_iface == rtif->ifi_index; } int waybar::modules::Network::getPreferredIface() { @@ -456,7 +458,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { char ifname[IF_NAMESIZE]; if_indextoname(rtif->ifi_index, ifname); // Auto detected network can also be assigned here - if (net->checkInterface(rtif->ifi_index, ifname) && net->ifid_ == -1) { + if (net->ifid_ == -1 && net->checkInterface(rtif, ifname)) { net->linked_ = true; net->ifname_ = ifname; net->ifid_ = rtif->ifi_index; @@ -481,7 +483,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { char ifname[IF_NAMESIZE]; if_indextoname(rtif->ifi_index, ifname); // Check for valid interface - if (net->checkInterface(rtif->ifi_index, ifname) && rtif->ifi_flags & IFF_RUNNING) { + if (rtif->ifi_flags & IFF_RUNNING && net->checkInterface(rtif, ifname)) { net->linked_ = true; net->ifname_ = ifname; net->ifid_ = rtif->ifi_index; @@ -493,6 +495,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { net->essid_.clear(); net->signal_strength_dbm_ = 0; net->signal_strength_ = 0; + net->frequency_ = 0; // Check for a new interface and get info auto new_iface = net->getPreferredIface(); if (new_iface != -1) { From b31a64ad0088aa8773b64f9eb6393f9f950f14be Mon Sep 17 00:00:00 2001 From: Lucas Lazare Date: Sat, 18 May 2019 09:13:00 -0400 Subject: [PATCH 05/10] Displaying in ko/s and kb/s instead of interval dependant unit --- src/modules/network.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index baa546da..8f767f0b 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -302,10 +302,10 @@ auto waybar::modules::Network::update() -> void { fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), fmt::arg("icon", getIcon(signal_strength_, connectiontype)), - fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull, "b")), - fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull, "b")), - fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down, "o")), - fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up, "o"))); + fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / interval_.count(), "b/s")), + fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / interval_.count(), "b/s")), + fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / interval_.count(), "o/s")), + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s"))); label_.set_markup(text); if (tooltipEnabled()) { if (!tooltip_format.empty()) { @@ -319,10 +319,10 @@ auto waybar::modules::Network::update() -> void { fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), fmt::arg("icon", getIcon(signal_strength_, connectiontype)), - fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull, "b")), - fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull, "b")), - fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down, "o")), - fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up, "o"))); + fmt::arg("bandwidthDownBits", pow_format(bandwidth_down * 8ull / interval_.count(), "b/s")), + fmt::arg("bandwidthUpBits", pow_format(bandwidth_up * 8ull / interval_.count(), "b/s")), + fmt::arg("bandwidthDownOctets", pow_format(bandwidth_down / interval_.count(), "o/s")), + fmt::arg("bandwidthUpOctets", pow_format(bandwidth_up / interval_.count(), "o/s"))); label_.set_tooltip_text(tooltip_text); } else { label_.set_tooltip_text(text); From 2c1a3d0430b64964214fd1815f405188c0578917 Mon Sep 17 00:00:00 2001 From: Lucas Lazare Date: Sat, 18 May 2019 09:17:17 -0400 Subject: [PATCH 06/10] Adding logging --- src/modules/network.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 8f767f0b..11917459 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -1,6 +1,7 @@ #include "modules/network.hpp" #include #include +#include namespace { @@ -12,6 +13,7 @@ namespace { std::ifstream netstat(NETSTAT_FILE); std::optional read_netstat(std::string_view category, std::string_view key) { if (!netstat) { + std::cerr << "Failed to open netstat file " << NETSTAT_FILE << '\n' << std::flush; return {}; } netstat.seekg(std::ios_base::beg); @@ -26,6 +28,7 @@ namespace { std::string read; while (std::getline(netstat, read) && !starts_with(read, category)); if (!starts_with(read, category)) { + std::cerr << "Category '" << category << "' not found in netstat file " << NETSTAT_FILE << '\n' << std::flush; return {}; } @@ -49,6 +52,7 @@ namespace { } if (r_it == read.end() && k_it != key.end()) { + std::cerr << "Key '" << key << "' not found in category '" << category << "' of netstat file " << NETSTAT_FILE << '\n' << std::flush; return {}; } From aa385e28b6c2c6e8e261b6b108f3635e86796b01 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 15:32:40 +0200 Subject: [PATCH 07/10] refactor: execute update on idle --- src/bar.cpp | 13 ++++++++----- src/modules/network.cpp | 41 ++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/bar.cpp b/src/bar.cpp index dd7b8805..09d7335c 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -272,11 +272,14 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos) { modules_right_.emplace_back(module); } module->dp.connect([module, &name] { - try { - module->update(); - } catch (const std::exception& e) { - std::cerr << name.asString() + ": " + e.what() << std::endl; - } + // Fix https://github.com/Alexays/Waybar/issues/320, proper way? + Glib::signal_idle().connect_once([module, &name] { + try { + module->update(); + } catch (const std::exception& e) { + std::cerr << name.asString() + ": " + e.what() << std::endl; + } + }); }); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 17795960..9c1dc84e 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -42,8 +42,6 @@ waybar::modules::Network::~Network() { nl_socket_drop_membership(ev_sock_, RTNLGRP_LINK); nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV4_IFADDR); nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV6_IFADDR); - nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV4_ROUTE); - nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV6_ROUTE); nl_close(ev_sock_); nl_socket_free(ev_sock_); } @@ -64,8 +62,6 @@ void waybar::modules::Network::createInfoSocket() { nl_socket_add_membership(ev_sock_, RTNLGRP_LINK); nl_socket_add_membership(ev_sock_, RTNLGRP_IPV4_IFADDR); nl_socket_add_membership(ev_sock_, RTNLGRP_IPV6_IFADDR); - nl_socket_add_membership(ev_sock_, RTNLGRP_IPV4_ROUTE); - nl_socket_add_membership(ev_sock_, RTNLGRP_IPV6_ROUTE); efd_ = epoll_create1(EPOLL_CLOEXEC); if (efd_ < 0) { throw std::runtime_error("Can't create epoll"); @@ -108,9 +104,12 @@ void waybar::modules::Network::createEventSocket() { void waybar::modules::Network::worker() { thread_timer_ = [this] { - if (ifid_ > 0) { - getInfo(); - dp.emit(); + { + std::lock_guard lock(mutex_); + if (ifid_ > 0) { + getInfo(); + dp.emit(); + } } thread_timer_.sleep_for(interval_); }; @@ -131,11 +130,9 @@ 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(); - } + std::string connectiontype; + std::string tooltip_format; + std::lock_guard lock(mutex_); if (ifid_ <= 0 || !linked_) { if (config_["format-disconnected"].isString()) { default_format_ = config_["format-disconnected"].asString(); @@ -187,8 +184,13 @@ auto waybar::modules::Network::update() -> void { fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), fmt::arg("icon", getIcon(signal_strength_, connectiontype))); - label_.set_markup(text); + if (text != label_.get_label()) { + label_.set_markup(text); + } if (tooltipEnabled()) { + if (tooltip_format.empty() && config_["tooltip-format"].isString()) { + tooltip_format = config_["tooltip-format"].asString(); + } if (!tooltip_format.empty()) { auto tooltip_text = fmt::format(tooltip_format, fmt::arg("essid", essid_), @@ -199,10 +201,11 @@ auto waybar::modules::Network::update() -> void { fmt::arg("ipaddr", ipaddr_), fmt::arg("cidr", cidr_), fmt::arg("frequency", frequency_), - fmt::arg("icon", getIcon(signal_strength_, - connectiontype))); - label_.set_tooltip_text(tooltip_text); - } else { + fmt::arg("icon", getIcon(signal_strength_, connectiontype))); + if (label_.get_tooltip_text() != text) { + label_.set_tooltip_text(tooltip_text); + } + } else if (label_.get_tooltip_text() != text) { label_.set_tooltip_text(text); } } @@ -464,7 +467,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { net->ifid_ = rtif->ifi_index; } // Check for valid interface - if (rtif->ifi_index == static_cast(net->ifid_)) { + if (rtif->ifi_index == net->ifid_) { // Get Iface and WIFI info net->getInterfaceAddress(); net->thread_timer_.wake_up(); @@ -472,7 +475,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) { } else if (nh->nlmsg_type == RTM_DELADDR) { auto rtif = static_cast(NLMSG_DATA(nh)); // Check for valid interface - if (rtif->ifi_index == static_cast(net->ifid_)) { + if (rtif->ifi_index == net->ifid_) { net->ipaddr_.clear(); net->netmask_.clear(); net->cidr_ = 0; From 67786c32a834abef00d5f6d096cb7ee0470a4b7f Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 15:45:18 +0200 Subject: [PATCH 08/10] fix(merge): re-add missing code --- src/modules/network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 34ce3305..d75d83a5 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -330,7 +330,7 @@ auto waybar::modules::Network::update() -> void { if (label_.get_tooltip_text() != text) { label_.set_tooltip_text(tooltip_text); } - } else { + } else if (label_.get_tooltip_text() != text) { label_.set_tooltip_text(text); } } From ff28de048289c21aa54ff88529f21823947f6ac6 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 16:07:55 +0200 Subject: [PATCH 09/10] feat(custom): update on click/scroll --- include/modules/custom.hpp | 2 ++ src/modules/custom.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/modules/custom.hpp b/include/modules/custom.hpp index 42663fd5..7ffac3d6 100644 --- a/include/modules/custom.hpp +++ b/include/modules/custom.hpp @@ -22,6 +22,8 @@ class Custom : public ALabel { void continuousWorker(); void parseOutputRaw(); void parseOutputJson(); + bool handleScroll(GdkEventScroll* e); + bool handleToggle(GdkEventButton* const& e); const std::string name_; std::string text_; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 4dbb80ab..de584476 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -79,6 +79,18 @@ void waybar::modules::Custom::refresh(int sig /*signal*/) { } } +bool waybar::modules::Custom::handleScroll(GdkEventScroll* e) { + auto ret = ALabel::handleScroll(e); + thread_.wake_up(); + return ret; +} + +bool waybar::modules::Custom::handleToggle(GdkEventButton* const& e) { + auto ret = ALabel::handleToggle(e); + thread_.wake_up(); + return ret; +} + auto waybar::modules::Custom::update() -> void { // Hide label if output is empty if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) { From 6ffc7ee3b3a8ead799aef9af3b69f4e50c533f45 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 18 May 2019 16:12:19 +0200 Subject: [PATCH 10/10] chore: 0.6.5 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 111b1a9a..8882e903 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project( 'waybar', 'cpp', 'c', - version: '0.6.4', + version: '0.6.5', license: 'MIT', default_options : [ 'cpp_std=c++17',