polybar: update to 3.7.2.
This commit is contained in:
parent
90839a0777
commit
cbf149521f
|
@ -0,0 +1,27 @@
|
|||
From 03d01afed688fdba0c7cd31934373c277d615606 Mon Sep 17 00:00:00 2001
|
||||
From: classabbyamp <dev@placeviolette.net>
|
||||
Date: Sun, 24 Mar 2024 17:16:29 -0400
|
||||
Subject: [PATCH] fix(modules/battery): make rate positive if negative
|
||||
|
||||
on the Lenovo X13s, the battery firmware returns a negative value for
|
||||
power_now, which is interpreted by the battery module as 0 because it
|
||||
converts the string to unsigned long. This should be read as a long
|
||||
instead, as the kernel specifies that power_now is an int:
|
||||
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/power_supply.h?h=v6.0.11#n99
|
||||
---
|
||||
src/modules/battery.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp
|
||||
index 4d966adca..7d7ac3799 100644
|
||||
--- a/src/modules/battery.cpp
|
||||
+++ b/src/modules/battery.cpp
|
||||
@@ -65,7 +65,7 @@ namespace modules {
|
||||
}
|
||||
|
||||
m_rate_reader = make_unique<rate_reader>([this] {
|
||||
- unsigned long rate{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};
|
||||
+ unsigned long rate{static_cast<unsigned long>(std::abs(std::strtol(file_util::contents(m_frate).c_str(), nullptr, 10)))};
|
||||
unsigned long volt{std::strtoul(file_util::contents(m_fvoltage).c_str(), nullptr, 10) / 1000UL};
|
||||
unsigned long now{std::strtoul(file_util::contents(m_fcapnow).c_str(), nullptr, 10)};
|
||||
unsigned long max{std::strtoul(file_util::contents(m_fcapfull).c_str(), nullptr, 10)};
|
|
@ -0,0 +1,71 @@
|
|||
From a4619a5138ce581c6cee79dbf0b47c85ac5467cf Mon Sep 17 00:00:00 2001
|
||||
From: classabbyamp <dev@placeviolette.net>
|
||||
Date: Sun, 24 Mar 2024 16:45:52 -0400
|
||||
Subject: [PATCH] fix(file_util::pick): ensure files are readable before
|
||||
picking them
|
||||
|
||||
the firmware of the Lenovo X13s does not expose charge_now or
|
||||
charge_full, but the files still exist, so file_util::pick() will still
|
||||
choose that over energy_now/energy_full. This leads to the battery
|
||||
module erroneously outputting "0%" at all times. If charge_now or
|
||||
charge_full is read, it will return ENODATA, so simply reading 1 char
|
||||
and checking the status should determine if the file should actually be
|
||||
picked.
|
||||
---
|
||||
include/utils/file.hpp | 1 +
|
||||
src/utils/file.cpp | 20 ++++++++++++++++++--
|
||||
2 files changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/utils/file.hpp b/include/utils/file.hpp
|
||||
index 8a34c6450..65ff10a53 100644
|
||||
--- a/include/utils/file.hpp
|
||||
+++ b/include/utils/file.hpp
|
||||
@@ -82,6 +82,7 @@ class fd_stream : public StreamType {
|
||||
|
||||
namespace file_util {
|
||||
bool exists(const string& filename);
|
||||
+ bool readable(const string& filename);
|
||||
bool is_file(const string& filename);
|
||||
bool is_dir(const string& filename);
|
||||
string pick(const vector<string>& filenames);
|
||||
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
|
||||
index 9511ad613..b9dce41a6 100644
|
||||
--- a/src/utils/file.cpp
|
||||
+++ b/src/utils/file.cpp
|
||||
@@ -152,6 +152,22 @@ namespace file_util {
|
||||
return stat(filename.c_str(), &buffer) == 0;
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Checks if the given file is actually readable
|
||||
+ *
|
||||
+ * Doing an actual read is necessary to confirm that reading
|
||||
+ * will actually succeed. For example, some battery firmware
|
||||
+ * will return ENODATA when charge_now is read, as it is not
|
||||
+ * implemented in the firmware, despite the file existing
|
||||
+ * and having a+r permissions.
|
||||
+ */
|
||||
+ bool readable(const string& filename) {
|
||||
+ char c;
|
||||
+ std::ifstream in(filename, std::ifstream::in);
|
||||
+ in.get(c);
|
||||
+ return in.good();
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Checks if the given path exists and is a file
|
||||
*/
|
||||
@@ -179,11 +195,11 @@ namespace file_util {
|
||||
}
|
||||
|
||||
/**
|
||||
- * Picks the first existing file out of given entries
|
||||
+ * Picks the first existing and readable file out of given entries
|
||||
*/
|
||||
string pick(const vector<string>& filenames) {
|
||||
for (auto&& f : filenames) {
|
||||
- if (exists(f)) {
|
||||
+ if (exists(f) && readable(f)) {
|
||||
return f;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
# Template file for 'polybar'
|
||||
pkgname=polybar
|
||||
version=3.7.1
|
||||
version=3.7.2
|
||||
revision=1
|
||||
build_style=cmake
|
||||
configure_args="-DBUILD_DOC_HTML=OFF $(vopt_bool alsa ENABLE_ALSA)
|
||||
|
@ -18,7 +18,7 @@ license="MIT"
|
|||
homepage="https://github.com/polybar/polybar"
|
||||
changelog="https://raw.githubusercontent.com/polybar/polybar/master/CHANGELOG.md"
|
||||
distfiles="https://github.com/polybar/polybar/releases/download/${version}/polybar-${version}.tar.gz"
|
||||
checksum=5de6ad385ba09dc453a4e5ec7054749a4882b5b21a62c17ae40bf7c90613ff0f
|
||||
checksum=e2feacbd02e7c94baed7f50b13bcbf307d95df0325c3ecae443289ba5b56af29
|
||||
# tries to download and build unstable/unreleased googletest during configure
|
||||
make_check=no
|
||||
|
||||
|
|
Loading…
Reference in New Issue