Merge pull request #1870 from nova-nowiz/feat/brightness-percent-exp
feat(backlight): added percentexp as format option
This commit is contained in:
@@ -36,9 +36,15 @@ auto waybar::modules::Backlight::update() -> void {
|
|||||||
|
|
||||||
if (best->get_powered()) {
|
if (best->get_powered()) {
|
||||||
event_box_.show();
|
event_box_.show();
|
||||||
|
|
||||||
const uint8_t percent =
|
const uint8_t percent =
|
||||||
best->get_max() == 0 ? 100 : round(best->get_actual() * 100.0f / best->get_max());
|
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
|
// Get the state and apply state-specific format if available
|
||||||
auto state = getState(percent);
|
auto state = getState(percent);
|
||||||
std::string current_format = format_;
|
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),
|
std::string desc =
|
||||||
fmt::arg("icon", getIcon(percent)));
|
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);
|
label_.set_markup(desc);
|
||||||
if (tooltipEnabled()) {
|
if (tooltipEnabled()) {
|
||||||
std::string tooltip_format;
|
std::string tooltip_format;
|
||||||
|
|||||||
Reference in New Issue
Block a user