feat(backlight): added percentexp as format option
Humans don't perceive light linearly and so an exponential curve is more appropriate to gauge the perceived brightness of the screen.
This commit is contained in:
@@ -179,9 +179,17 @@ 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);
|
||||
|
||||
label_.set_markup(fmt::format(format_, fmt::arg("percent", std::to_string(percent)),
|
||||
fmt::arg("percentexp", std::to_string(percent_exp)),
|
||||
fmt::arg("icon", getIcon(percent))));
|
||||
getState(percent);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user