mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-17 18:05:32 +12:00
use capacity as default for battery percentage, less complicated and matches desktop percent exactly
This commit is contained in:
parent
ab294bfc10
commit
f6d8c4a044
|
@ -757,7 +757,14 @@ namespace Cpu {
|
||||||
long seconds = -1;
|
long seconds = -1;
|
||||||
|
|
||||||
//? Try to get battery percentage
|
//? Try to get battery percentage
|
||||||
if (b.use_energy_or_charge) {
|
if (percent < 0) {
|
||||||
|
try {
|
||||||
|
percent = stoll(readfile(b.base_dir / "capacity", "-1"));
|
||||||
|
}
|
||||||
|
catch (const std::invalid_argument&) { }
|
||||||
|
catch (const std::out_of_range&) { }
|
||||||
|
}
|
||||||
|
if (b.use_energy_or_charge and percent < 0) {
|
||||||
try {
|
try {
|
||||||
percent = round(100.0 * stoll(readfile(b.energy_now, "-1")) / stoll(readfile(b.energy_full, "1")));
|
percent = round(100.0 * stoll(readfile(b.energy_now, "-1")) / stoll(readfile(b.energy_full, "1")));
|
||||||
}
|
}
|
||||||
|
@ -771,13 +778,6 @@ namespace Cpu {
|
||||||
catch (const std::invalid_argument&) { }
|
catch (const std::invalid_argument&) { }
|
||||||
catch (const std::out_of_range&) { }
|
catch (const std::out_of_range&) { }
|
||||||
}
|
}
|
||||||
if (percent < 0) {
|
|
||||||
try {
|
|
||||||
percent = stoll(readfile(b.base_dir / "capacity", "-1"));
|
|
||||||
}
|
|
||||||
catch (const std::invalid_argument&) { }
|
|
||||||
catch (const std::out_of_range&) { }
|
|
||||||
}
|
|
||||||
if (percent < 0) {
|
if (percent < 0) {
|
||||||
has_battery = false;
|
has_battery = false;
|
||||||
return {0, 0, ""};
|
return {0, 0, ""};
|
||||||
|
|
Loading…
Reference in a new issue