diff --git a/TODO.md b/TODO.md index 12d5ba0..113b586 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,13 @@ ## 2.3 +- [x] Do not require only basename of path to udev devices; let it manage full path the same way +- [x] Install license file in /usr/share/licenses/clightd/ + +## 2.4 - [ ] Add gamma (and dpms + idle) support on wayland (wlroots) https://github.com/swaywm/wlroots/blob/master/examples/gamma-control.c https://github.com/swaywm/wlroots/blob/master/examples/idle.c https://github.com/minus7/redshift/tree/wayland -- [x] Install license file in /usr/share/licenses/clightd/ - ## 2.X - [ ] Keep it up to date with possible ddcutil api changes diff --git a/inc/udev.h b/inc/udev.h index c6936fa..b40d0e6 100644 --- a/inc/udev.h +++ b/inc/udev.h @@ -2,5 +2,5 @@ extern struct udev *udev; -void get_udev_device(const char *backlight_interface, const char *subsystem, +void get_udev_device(const char *interface, const char *subsystem, sd_bus_error **ret_error, struct udev_device **dev); diff --git a/src/udev.c b/src/udev.c index e887a6a..0aee83a 100644 --- a/src/udev.c +++ b/src/udev.c @@ -18,13 +18,17 @@ static void get_first_matching_device(struct udev_device **dev, const char *subs udev_enumerate_unref(enumerate); } -void get_udev_device(const char *backlight_interface, const char *subsystem, +void get_udev_device(const char *interface, const char *subsystem, sd_bus_error **ret_error, struct udev_device **dev) { /* if no backlight_interface is specified, try to get first matching device */ - if (!backlight_interface || !strlen(backlight_interface)) { + if (!interface || !strlen(interface)) { get_first_matching_device(dev, subsystem); } else { - *dev = udev_device_new_from_subsystem_sysname(udev, subsystem, backlight_interface); + char *name = strrchr(interface, '/'); + if (name) { + return get_udev_device(++name, subsystem, ret_error, dev); + } + *dev = udev_device_new_from_subsystem_sysname(udev, subsystem, interface); } if (!(*dev) && ret_error) { sd_bus_error_set_errno(*ret_error, ENODEV);