[packages/polybar] upstream patch for increasing precision of network speed
atler
atler at pld-linux.org
Tue Sep 21 18:38:06 CEST 2021
commit 6399b72aed286892a4c8f661600767fde5d311eb
Author: Jan Palus <atler at pld-linux.org>
Date: Tue Sep 21 18:37:09 2021 +0200
upstream patch for increasing precision of network speed
from: https://github.com/polybar/polybar/pull/2054
polybar-net-speedrate-precison.patch | 42 ++++++++++++++++++++++++++++++++++++
polybar.spec | 2 ++
2 files changed, 44 insertions(+)
---
diff --git a/polybar.spec b/polybar.spec
index 8eba7a2..6f4c163 100644
--- a/polybar.spec
+++ b/polybar.spec
@@ -7,6 +7,7 @@ Group: X11/Window Managers
Source0: https://github.com/polybar/polybar/releases/download/%{version}/%{name}-%{version}.tar.gz
# Source0-md5: 3a9b19709d49ac9e86d875ed2570ff91
Patch0: %{name}-mpd-overhead.patch
+Patch1: %{name}-net-speedrate-precison.patch
URL: https://polybar.github.io/
BuildRequires: alsa-lib-devel
BuildRequires: cairo-devel
@@ -66,6 +67,7 @@ zsh-completion for polybar.
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%build
install -d build
diff --git a/polybar-net-speedrate-precison.patch b/polybar-net-speedrate-precison.patch
new file mode 100644
index 0000000..0cf2172
--- /dev/null
+++ b/polybar-net-speedrate-precison.patch
@@ -0,0 +1,42 @@
+From 6208c9e2454e00f61a0980ca3fdae630e52a9548 Mon Sep 17 00:00:00 2001
+From: Jan Palus <atler at pld-linux.org>
+Date: Thu, 9 Apr 2020 01:39:27 +0200
+Subject: [PATCH] net: increase speedrate precision
+
+more granular units need lower precision, while less granular need
+higher precision. assume sane default of:
+
+unit | precision
+KB | 0
+MB | 1
+GB | 2
+---
+ src/adapters/net.cpp | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/adapters/net.cpp b/src/adapters/net.cpp
+index 40c8b89fd7..4860309577 100644
+--- a/src/adapters/net.cpp
++++ b/src/adapters/net.cpp
+@@ -229,15 +229,17 @@ namespace net {
+ float time_diff = duration.count();
+ float speedrate = bytes_diff / time_diff;
+
+- vector<string> suffixes{"GB", "MB"};
++ vector<pair<string,int>> units{make_pair("GB",2), make_pair("MB",1)};
+ string suffix{"KB"};
++ int precision = 0;
+
+ while ((speedrate /= 1000) > 999) {
+- suffix = suffixes.back();
+- suffixes.pop_back();
++ suffix = units.back().first;
++ precision = units.back().second;
++ units.pop_back();
+ }
+
+- return sstream() << std::setw(minwidth) << std::setfill(' ') << std::setprecision(0) << std::fixed << speedrate
++ return sstream() << std::setw(minwidth) << std::setfill(' ') << std::setprecision(precision) << std::fixed << speedrate
+ << " " << suffix << "/s";
+ }
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/polybar.git/commitdiff/6399b72aed286892a4c8f661600767fde5d311eb
More information about the pld-cvs-commit
mailing list