feat: full-at (#649)

* feat: full-at

* fix(man): typo
This commit is contained in:
Alex
2020-04-05 16:56:51 +02:00
committed by GitHub
parent d5bd3be8de
commit 8e0f3c7ddf
2 changed files with 14 additions and 0 deletions

View File

@ -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;
}
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};
} catch (const std::exception& e) {
spdlog::error("Battery: {}", e.what());