mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(percent): adds a percent class to numeric modules
This commit is contained in:
@ -179,8 +179,13 @@ auto waybar::modules::Backlight::update() -> void {
|
||||
}
|
||||
|
||||
const auto percent = best->get_max() == 0 ? 100 : best->get_actual() * 100 / best->get_max();
|
||||
const auto percentClass = "percent" + std::to_string(int(std::ceil(percent/5)*5));
|
||||
|
||||
label_.set_markup(fmt::format(
|
||||
format_, fmt::arg("percent", std::to_string(percent)), fmt::arg("icon", getIcon(percent))));
|
||||
label_.get_style_context()->remove_class(old_percent_);
|
||||
label_.get_style_context()->add_class(percentClass);
|
||||
old_percent_ = percentClass;
|
||||
} else {
|
||||
if (!previous_best_.has_value()) {
|
||||
return;
|
||||
|
@ -144,8 +144,13 @@ auto waybar::modules::Battery::update() -> void {
|
||||
std::transform(status.begin(), status.end(), status.begin(), ::tolower);
|
||||
auto format = format_;
|
||||
auto state = getState(capacity);
|
||||
auto capacity_class = "percent" + std::to_string(int(std::ceil(capacity/5)*5));
|
||||
label_.get_style_context()->remove_class(old_status_);
|
||||
label_.get_style_context()->remove_class(old_capacity_);
|
||||
label_.get_style_context()->add_class(status);
|
||||
label_.get_style_context()->add_class(capacity_class);
|
||||
old_capacity_ = capacity_class;
|
||||
std::cout << fmt::format(capacity_class);
|
||||
old_status_ = status;
|
||||
if (!state.empty() && config_["format-" + status + "-" + state].isString()) {
|
||||
format = config_["format-" + status + "-" + state].asString();
|
||||
|
@ -19,7 +19,11 @@ auto waybar::modules::Cpu::update() -> void {
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(tooltip);
|
||||
}
|
||||
auto percent_class = "percent" + std::to_string(int(std::ceil(cpu_usage/5)*5));
|
||||
label_.set_markup(fmt::format(format_, fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
||||
label_.get_style_context()->remove_class(old_usage_);
|
||||
label_.get_style_context()->add_class(percent_class);
|
||||
old_usage_ = percent_class;
|
||||
}
|
||||
|
||||
uint16_t waybar::modules::Cpu::getCpuLoad() {
|
||||
|
Reference in New Issue
Block a user