Changed: Disable battery monitoring if it fails instead of exiting

This commit is contained in:
Jakob P. Liljenberg 2022-06-21 14:42:06 +02:00 committed by GitHub
parent 83e9942d67
commit 7d86602ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -513,6 +513,7 @@ namespace Cpu {
//? Get paths to needed files and check for valid values on first run
if (batteries.empty() and has_battery) {
try {
if (fs::exists("/sys/class/power_supply")) {
for (const auto& d : fs::directory_iterator("/sys/class/power_supply")) {
//? Only consider online power supplies of type Battery or UPS
@ -559,6 +560,10 @@ namespace Cpu {
Config::available_batteries.push_back(bat_dir.filename());
}
}
}
catch (...) {
batteries.clear();
}
if (batteries.empty()) {
has_battery = false;
return {0, 0, ""};