mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
parent
d5bd3be8de
commit
8e0f3c7ddf
@ -18,6 +18,10 @@ The *battery* module displays the current capacity and state (eg. charging) of y
|
|||||||
typeof: string ++
|
typeof: string ++
|
||||||
The adapter to monitor, as in /sys/class/power_supply/ instead of auto detect.
|
The adapter to monitor, as in /sys/class/power_supply/ instead of auto detect.
|
||||||
|
|
||||||
|
*full-at* ++
|
||||||
|
typeof: integer ++
|
||||||
|
Define the max percentage of the battery, usefull for an old battery, e.g. 96
|
||||||
|
|
||||||
*interval* ++
|
*interval* ++
|
||||||
typeof: integer ++
|
typeof: integer ++
|
||||||
default: 60 ++
|
default: 60 ++
|
||||||
|
@ -115,6 +115,16 @@ const std::tuple<uint8_t, float, std::string> waybar::modules::Battery::getInfos
|
|||||||
time_remaining = -(float)(total_energy_full - total_energy) / total_power;
|
time_remaining = -(float)(total_energy_full - total_energy) / total_power;
|
||||||
}
|
}
|
||||||
uint16_t capacity = total / batteries_.size();
|
uint16_t capacity = total / batteries_.size();
|
||||||
|
// Handle full-at
|
||||||
|
if (config_["full-at"].isUInt()) {
|
||||||
|
auto full_at = config_["full-at"].asUInt();
|
||||||
|
if (full_at < 100) {
|
||||||
|
capacity = static_cast<float>(capacity / full_at) * 100;
|
||||||
|
if (capacity > full_at) {
|
||||||
|
capacity = full_at;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return {capacity, time_remaining, status};
|
return {capacity, time_remaining, status};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
spdlog::error("Battery: {}", e.what());
|
spdlog::error("Battery: {}", e.what());
|
||||||
|
Loading…
Reference in New Issue
Block a user