Skip to content

Commit

Permalink
Avoid requiring only basename of udev device syspath. Manage fullpath…
Browse files Browse the repository at this point in the history
… too.
  • Loading branch information
FedeDP committed Sep 1, 2018
1 parent da26838 commit 75b1f00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion inc/udev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
10 changes: 7 additions & 3 deletions src/udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 75b1f00

Please sign in to comment.