Reapply "Make battery module update on plugging/unplugging again (refs #2519)"

This reverts commit bb2c67ebad.
This commit is contained in:
schmop
2025-10-31 13:26:27 +01:00
parent 161367d961
commit 4e25871655
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));