Skip to content

Commit

Permalink
Merge pull request #1937 from cyrinux/fix/battery-time-remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays committed Jan 13, 2023
2 parents f0bead3 + 120cba0 commit d71a456
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,12 @@ const std::tuple<uint8_t, float, std::string, float> waybar::modules::Battery::g

float time_remaining{0.0f};
if (status == "Discharging" && time_to_empty_now_exists) {
if (time_to_empty_now != 0) time_remaining = (float)time_to_empty_now / 1000.0f;
if (time_to_empty_now != 0) time_remaining = (float)time_to_empty_now / 3600.0f;
} else if (status == "Discharging" && total_power_exists && total_energy_exists) {
if (total_power != 0) time_remaining = (float)total_energy / total_power;
} else if (status == "Charging" && time_to_full_now_exists) {
if (time_to_full_now_exists && (time_to_full_now != 0))
time_remaining = -(float)time_to_full_now / 1000.0f;
time_remaining = -(float)time_to_full_now / 3600.0f;
// If we've turned positive it means the battery is past 100% and so just report that as no
// time remaining
if (time_remaining > 0.0f) time_remaining = 0.0f;
Expand Down

0 comments on commit d71a456

Please sign in to comment.