Merge pull request #3474 from schmop/battery-plugging-instant-updates

Make battery module update on plugging/unplugging again (refs #2519)
This commit is contained in:
Alexis Rouillard
2025-01-25 09:20:02 +01:00
committed by GitHub
4 changed files with 51 additions and 35 deletions

View File

@ -1,4 +1,5 @@
#include "util/backlight_backend.hpp"
#include "util/udev_deleter.hpp"
#include <fmt/core.h>
#include <spdlog/spdlog.h>
@ -29,22 +30,6 @@ class FileDescriptor {
int fd_;
};
struct UdevDeleter {
void operator()(udev *ptr) { udev_unref(ptr); }
};
struct UdevDeviceDeleter {
void operator()(udev_device *ptr) { udev_device_unref(ptr); }
};
struct UdevEnumerateDeleter {
void operator()(udev_enumerate *ptr) { udev_enumerate_unref(ptr); }
};
struct UdevMonitorDeleter {
void operator()(udev_monitor *ptr) { udev_monitor_unref(ptr); }
};
void check_eq(int rc, int expected, const char *message = "eq, rc was: ") {
if (rc != expected) {
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));