Skip to content

feat(battery): added support for battery state-based classes on the entire waybar #2810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 23, 2024
Prev Previous commit
Next Next commit
fixed early dereference error
  • Loading branch information
ArneshRC committed Jan 19, 2024
commit d14a4a2b1aa6b4a9af15b345f1435e68103c5d26
3 changes: 2 additions & 1 deletion src/modules/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
return classname.rfind(prefix, 0) == 0;
});

auto old_class = *old_class_it;
auto new_class = prefix + state;

// If the bar doesn't have any `battery-` class
Expand All @@ -712,6 +711,8 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
return;
}

auto old_class = *old_class_it;

// If the bar has a `battery-` class,
// but `state` is empty
if(state.empty()) {
Expand Down