mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-18 11:22:46 +12:00
add battery percentage calculation in charge case
This commit is contained in:
parent
ee61700a44
commit
ab294bfc10
|
@ -764,6 +764,13 @@ namespace Cpu {
|
|||
catch (const std::invalid_argument&) { }
|
||||
catch (const std::out_of_range&) { }
|
||||
}
|
||||
if (b.use_energy_or_charge == true and percent < 0) {
|
||||
try {
|
||||
percent = round(100.0 * stoll(readfile(b.charge_now, "-1")) / stoll(readfile(b.charge_full, "1")));
|
||||
}
|
||||
catch (const std::invalid_argument&) { }
|
||||
catch (const std::out_of_range&) { }
|
||||
}
|
||||
if (percent < 0) {
|
||||
try {
|
||||
percent = stoll(readfile(b.base_dir / "capacity", "-1"));
|
||||
|
|
Loading…
Reference in a new issue