From 27df7a9aa7c76de901ad3ad8f9c5fcb1b3af3d8d Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Sun, 23 Jan 2022 18:36:59 -0700 Subject: [PATCH] battery: read status with spaces According to the [sysfs class power ABI], /sys/class/power_supply//status may contain "Not charging". This is already handled by status_gt() and update() (where ' ' is converted to '-' for use in config keys) but was not being read due to skipws. Read with std::getline() to handle this case. [sysfs class power ABI]: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power Fixes: #1139 Signed-off-by: Kevin Locke --- 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 2656769..c0075a4 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -161,7 +161,7 @@ const std::tuple waybar::modules::Battery::g uint32_t energy_now; uint32_t energy_full_design; std::string _status; - std::ifstream(bat / "status") >> _status; + std::getline(std::ifstream(bat / "status"), _status); // Some battery will report current and charge in μA/μAh. // Scale these by the voltage to get μW/μWh.