From e0f29dbf71caa9615e20a187bc525271181f1724 Mon Sep 17 00:00:00 2001 From: Andrei Costescu Date: Sat, 28 May 2022 10:39:43 +0200 Subject: [PATCH 1/2] Add bandwidth in bytes to 5 waybar-network --- man/waybar-network.5.scd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index f8bdd65d..b0a38b27 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -153,6 +153,10 @@ Addressed by *network* *{bandwidthDownOctets}*: Instant down speed in octets/seconds. +*{bandwidthUpBytes}*: Instant up speed in bytes/seconds. + +*{bandwidthDownByes}*: Instant down speed in bytes/seconds. + *{icon}*: Icon, as defined in *format-icons*. # EXAMPLES From 4e2305639bde32742dc84104732c67bbc5dfd195 Mon Sep 17 00:00:00 2001 From: Andrei Costescu Date: Sat, 28 May 2022 10:54:10 +0200 Subject: [PATCH 2/2] Add option for displaying total bandwidth --- man/waybar-network.5.scd | 8 +++++++- src/modules/network.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/man/waybar-network.5.scd b/man/waybar-network.5.scd index b0a38b27..a80737d4 100644 --- a/man/waybar-network.5.scd +++ b/man/waybar-network.5.scd @@ -149,13 +149,19 @@ Addressed by *network* *{bandwidthDownBits}*: Instant down speed in bits/seconds. +*{bandwidthTotalBits}*: Instant total speed in bits/seconds. + *{bandwidthUpOctets}*: Instant up speed in octets/seconds. *{bandwidthDownOctets}*: Instant down speed in octets/seconds. +*{bandwidthTotalOctets}*: Instant total speed in octets/seconds. + *{bandwidthUpBytes}*: Instant up speed in bytes/seconds. -*{bandwidthDownByes}*: Instant down speed in bytes/seconds. +*{bandwidthDownBytes}*: Instant down speed in bytes/seconds. + +*{bandwidthTotalBytes}*: Instant total speed in bytes/seconds. *{icon}*: Icon, as defined in *format-icons*. diff --git a/src/modules/network.cpp b/src/modules/network.cpp index 0d0a39c8..720540f1 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -339,10 +339,13 @@ auto waybar::modules::Network::update() -> void { fmt::arg("icon", getIcon(signal_strength_, state_)), 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("bandwidthTotalBits", pow_format((bandwidth_up + bandwidth_down) * 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")), + fmt::arg("bandwidthTotalOctets", pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "o/s")), fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / interval_.count(), "B/s")), - fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s"))); + fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s")), + fmt::arg("bandwidthTotalBytes", pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "B/s"))); if (text.compare(label_.get_label()) != 0) { label_.set_markup(text); if (text.empty()) { @@ -366,10 +369,13 @@ auto waybar::modules::Network::update() -> void { 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("bandwidthTotalBits", pow_format((bandwidth_up + bandwidth_down) * 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")), + fmt::arg("bandwidthTotalOctets", pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "o/s")), fmt::arg("bandwidthDownBytes", pow_format(bandwidth_down / interval_.count(), "B/s")), - fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s"))); + fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s")), + fmt::arg("bandwidthTotalBytes", pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "B/s"))); if (label_.get_tooltip_text() != tooltip_text) { label_.set_tooltip_text(tooltip_text); }