1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

fix(battery): check without using path_battery

This commit is contained in:
NBonaparte 2018-02-02 00:31:00 -08:00 committed by Patrick Ziegler
parent 539e2e09cf
commit 4d48ffed83

View file

@ -5,6 +5,7 @@
#include "drawtypes/ramp.hpp" #include "drawtypes/ramp.hpp"
#include "utils/file.hpp" #include "utils/file.hpp"
#include "utils/math.hpp" #include "utils/math.hpp"
#include "utils/string.hpp"
#include "modules/meta/base.inl" #include "modules/meta/base.inl"
@ -82,11 +83,11 @@ namespace modules {
}); });
// Make consumption reader // Make consumption reader
m_consumption_reader = make_unique<consumption_reader>([this,path_battery] { m_consumption_reader = make_unique<consumption_reader>([this] {
float consumption; float consumption;
// if the rate we found was the current, calculate power (P = I*V) // if the rate we found was the current, calculate power (P = I*V)
if (m_frate == path_battery + "current_now") { if (string_util::contains(m_frate, "current_now")) {
unsigned long current{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)}; unsigned long current{std::strtoul(file_util::contents(m_frate).c_str(), nullptr, 10)};
unsigned long voltage{std::strtoul(file_util::contents(m_fvoltage).c_str(), nullptr, 10)}; unsigned long voltage{std::strtoul(file_util::contents(m_fvoltage).c_str(), nullptr, 10)};