Backlight: avoid crash on getting brightness fails
Reading brightness value for backlight device can fail intermittently (particularly when using ddcci-driver-linux). Handle this more gracefully rather than crashing
This commit is contained in:
parent
89be55b00b
commit
1af7191740
|
@ -214,12 +214,10 @@ void waybar::modules::Backlight::upsert_device(ForwardIt first, ForwardIt last,
|
||||||
strncmp(name, "amdgpu_bl", 9) == 0 ? "brightness" : "actual_brightness";
|
strncmp(name, "amdgpu_bl", 9) == 0 ? "brightness" : "actual_brightness";
|
||||||
|
|
||||||
const char *actual = udev_device_get_sysattr_value(dev, actual_brightness_attr);
|
const char *actual = udev_device_get_sysattr_value(dev, actual_brightness_attr);
|
||||||
check_nn(actual);
|
const int actual_int = actual == nullptr ? 0 : std::stoi(actual);
|
||||||
const int actual_int = std::stoi(actual);
|
|
||||||
|
|
||||||
const char *max = udev_device_get_sysattr_value(dev, "max_brightness");
|
const char *max = udev_device_get_sysattr_value(dev, "max_brightness");
|
||||||
check_nn(max);
|
const int max_int = max == nullptr ? 0 : std::stoi(max);
|
||||||
const int max_int = std::stoi(max);
|
|
||||||
|
|
||||||
auto found =
|
auto found =
|
||||||
std::find_if(first, last, [name](const auto &device) { return device.name() == name; });
|
std::find_if(first, last, [name](const auto &device) { return device.name() == name; });
|
||||||
|
|
Loading…
Reference in New Issue