mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
chore: lint
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
#include "modules/battery.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
@ -696,17 +697,16 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
|
||||
auto classes = bar_.window.get_style_context()->list_classes();
|
||||
const std::string prefix = "battery-";
|
||||
|
||||
auto old_class_it = std::find_if(classes.begin(), classes.end(),
|
||||
[&prefix](auto classname) {
|
||||
return classname.rfind(prefix, 0) == 0;
|
||||
});
|
||||
auto old_class_it = std::find_if(classes.begin(), classes.end(), [&prefix](auto classname) {
|
||||
return classname.rfind(prefix, 0) == 0;
|
||||
});
|
||||
|
||||
auto new_class = prefix + state;
|
||||
|
||||
// If the bar doesn't have any `battery-` class
|
||||
if(old_class_it == classes.end()) {
|
||||
if(!state.empty()) {
|
||||
bar_.window.get_style_context()->add_class(new_class);
|
||||
if (old_class_it == classes.end()) {
|
||||
if (!state.empty()) {
|
||||
bar_.window.get_style_context()->add_class(new_class);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -715,14 +715,14 @@ void waybar::modules::Battery::setBarClass(std::string& state) {
|
||||
|
||||
// If the bar has a `battery-` class,
|
||||
// but `state` is empty
|
||||
if(state.empty()) {
|
||||
if (state.empty()) {
|
||||
bar_.window.get_style_context()->remove_class(old_class);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the bar has a `battery-` class,
|
||||
// and `state` is NOT empty
|
||||
if(old_class != new_class) {
|
||||
if (old_class != new_class) {
|
||||
bar_.window.get_style_context()->remove_class(old_class);
|
||||
bar_.window.get_style_context()->add_class(new_class);
|
||||
}
|
||||
|
Reference in New Issue
Block a user