diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index 8f0d583f..367d6434 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -36,9 +36,15 @@ auto waybar::modules::Backlight::update() -> void { if (best->get_powered()) { event_box_.show(); + const uint8_t percent = best->get_max() == 0 ? 100 : round(best->get_actual() * 100.0f / best->get_max()); + const uint8_t percent_exp = + best->get_max() == 0 + ? 100 + : roundf(powf((float)best->get_actual() / best->get_max(), 1.0f / 2.718f) * 100); + // Get the state and apply state-specific format if available auto state = getState(percent); std::string current_format = format_; @@ -49,8 +55,10 @@ auto waybar::modules::Backlight::update() -> void { } } - std::string desc = fmt::format(fmt::runtime(current_format), fmt::arg("percent", percent), - fmt::arg("icon", getIcon(percent))); + std::string desc = + fmt::format(fmt::runtime(current_format), fmt::arg("percent", percent), + fmt::arg("percent_exp", percent_exp), fmt::arg("icon", getIcon(percent)), + fmt::arg("icon_exp", getIcon(percent_exp))); label_.set_markup(desc); if (tooltipEnabled()) { std::string tooltip_format;