[BUG] Luxafor devices generate too many udev rules
JnyJny opened this issue · 1 comments
Software Versions:
- Operating System: Any
- Python version: Any
- BusyLight version: Latest
General Type of Problem
- Command-line
Describe the Problem
The udev-rules
subcommand 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"
...
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.