From 401ea05dd830e7cf6ef52a03aa6b2dc53587891d Mon Sep 17 00:00:00 2001 From: Jannusch Bigge Date: Tue, 16 Jun 2020 12:30:21 +0200 Subject: [PATCH] add check that all batteries from type battery --- src/modules/battery.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 406b4a3..beb0554 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -53,8 +53,13 @@ void waybar::modules::Battery::getBatteries() { auto bat_defined = config_["bat"].isString(); if (((bat_defined && dir_name == config_["bat"].asString()) || !bat_defined) && fs::exists(node.path() / "capacity") && fs::exists(node.path() / "uevent") && - fs::exists(node.path() / "status")) { - batteries_.push_back(node.path()); + fs::exists(node.path() / "status") && fs::exists(node.path() / "type")) { + std::string type; + std::ifstream(node.path() / "type") >> type; + + if (!type.compare("Battery")){ + batteries_.push_back(node.path()); + } } auto adap_defined = config_["adapter"].isString(); if (((adap_defined && dir_name == config_["adapter"].asString()) || !adap_defined) &&