Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Luxafor devices generate too many udev rules #225

Open
1 task done
JnyJny opened this issue Jan 14, 2023 · 1 comment
Open
1 task done

[BUG] Luxafor devices generate too many udev rules #225

JnyJny opened this issue Jan 14, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@JnyJny
Copy link
Owner

JnyJny commented Jan 14, 2023

Software Versions:

  • Operating System: Any
  • Python version: Any
  • BusyLight version: Latest

General Type of Problem

  • Command-line

Describe the Problem
The udev-rulessubcommand generates four different entries for Luxafor products when one would suffice. Luxafor devices share the same vendor and product identifiers and are disambiguated by their USB accessed product_string attribute. The udev subsystem can be configured to perform different actions based on the product_string value, however there isn't any special-case handling required and a single set of rules would cover all four supported Luxafor devices (BT, Flag, Mute, and Orb).

$ busylight udev-rules
...
# Rules for Luxafor Family of Devices: 1
# 1 Luxafor Flag
KERNEL=="hidraw*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
# Rules for Luxafor Family of Devices: 1
# 1 Luxafor BT
KERNEL=="hidraw*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
# Rules for Luxafor Family of Devices: 1
# 1 Luxafor Mute
KERNEL=="hidraw*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
# Rules for Luxafor Family of Devices: 1
# 1 Luxafor Orb
KERNEL=="hidraw*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
...

Expected Behavior
Only one udev rule generated for supported Luxafor devices:

$ busylight udev-rules
...
# Rules for Luxafor Family of Devices: 1
# 1 Luxafor BT, Flag, Mute, Orb
KERNEL=="hidraw*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="f372", MODE="0666"
...
@JnyJny JnyJny added the bug Something isn't working label Jan 14, 2023
@JnyJny JnyJny self-assigned this Jan 14, 2023
@JnyJny JnyJny changed the title [BUG] [BUG] Luxafor devices generate too many udev rules Jan 14, 2023
@JnyJny
Copy link
Owner Author

JnyJny commented Jan 14, 2023

The class method busylight.lights.hidlight.HIDLight.udev_rules invokes udev_rules for each of its subclasses. While the subclass "tree" is walked, the current subclass has no knowledge of previous invocations of udev_rules. As the current implementation stands, I don't see an easy way to fix this without re-writing and changing the class method substantially.

Each Luxafor light subclass is invoked separately by udev_rules so dedupe'ing entries would require having all the device information collected before the rule strings are generated. This would entail changing the return values of udev_rules from a list of strings to a list of tuples (or similar), dedup'ing the tuples and then generating the formatted udev rule strings. I could bubble that change in the interface up to the busylight.lights.light.Light.udev_rules class method and leave it to the command line invocation to produce the formatted output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant