mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-28 15:21:20 +12:00
Changed: Disable battery monitoring if it fails instead of exiting
This commit is contained in:
parent
83e9942d67
commit
7d86602ede
1 changed files with 46 additions and 41 deletions
|
@ -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, ""};
|
||||
|
|
Loading…
Reference in a new issue