Fix battery not showing for some devices

Adds 'bat-compatibility' boolean checking from configuration file.
pull/2494/head
KanuX-14 2023-09-10 14:41:40 -03:00
parent 309edd0585
commit 60611e9c2b
1 changed files with 3 additions and 1 deletions

View File

@ -100,9 +100,11 @@ void waybar::modules::Battery::refreshBatteries() {
}
auto dir_name = node.path().filename();
auto bat_defined = config_["bat"].isString();
bool bat_compatibility = config_["bat-compatibility"].asBool();
if (((bat_defined && dir_name == config_["bat"].asString()) || !bat_defined) &&
(fs::exists(node.path() / "capacity") || fs::exists(node.path() / "charge_now")) &&
fs::exists(node.path() / "uevent") && fs::exists(node.path() / "status") &&
fs::exists(node.path() / "uevent") &&
(fs::exists(node.path() / "status") || bat_compatibility) &&
fs::exists(node.path() / "type")) {
std::string type;
std::ifstream(node.path() / "type") >> type;