mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-14 07:02:30 +02:00
feat: backlight slider
This commit is contained in:
@ -188,11 +188,13 @@ void BacklightBackend::set_previous_best_device(const BacklightDevice *device) {
|
||||
}
|
||||
}
|
||||
|
||||
void BacklightBackend::set_brightness(std::string preferred_device, int brightness) {
|
||||
void BacklightBackend::set_scaled_brightness(std::string preferred_device, int brightness) {
|
||||
GET_BEST_DEVICE(best, (*this), preferred_device);
|
||||
|
||||
if (best != nullptr) {
|
||||
set_brightness_internal(best->name(), brightness, best->get_max());
|
||||
const auto max = best->get_max();
|
||||
const auto abs_val = static_cast<int>(round(brightness * max / 100.0f));
|
||||
set_brightness_internal(best->name(), abs_val, best->get_max());
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,6 +223,16 @@ void BacklightBackend::set_brightness_internal(std::string device_name, int brig
|
||||
login_proxy_->call_sync("SetBrightness", call_args);
|
||||
}
|
||||
|
||||
int BacklightBackend::get_scaled_brightness(std::string preferred_device) {
|
||||
GET_BEST_DEVICE(best, (*this), preferred_device);
|
||||
|
||||
if (best != nullptr) {
|
||||
return best->get_actual() * 100 / best->get_max();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class ForwardIt, class Inserter>
|
||||
void BacklightBackend::upsert_device(ForwardIt first, ForwardIt last, Inserter inserter,
|
||||
udev_device *dev) {
|
||||
|
Reference in New Issue
Block a user