Skip to content

udev: Add led support

Florian RICHER requested to merge florianricher/solid:add-leds-support into master

General information about how work my implementation in back.

For led device, i have the following Linux files.

  • color => Return color name (Ex: "rgb,white,yellow") is very arbitrary and can not exist. [Not used now because is very arbitrary]
  • max_brightness => Return max valid value. (Ex: 1 for simple led or 255 if brightness can be managed for example)
  • brightness => Current integer value of brightness, we can set new value with "echo [value] > brightness"

For RGB, we have other files.

  • multi_index => Return index for each "channel" separate by space. (Ex: "red green blue")
  • multi_intensity => Return value for each "channel" separate by space. (Ex: "255 0 0")

I tested on Playstation 5 Controller leds (rgb, player1, player2, ....), on my keyboard (basic led implementation), Oneplus 6 (Yellow flash, White flash)

My implementation

Implement basic led support

  • max brightness : int
  • get brightness : int
  • set brightness(int) : bool

Require +w permission on device_path/brightness

  • colorSupport : bool

Return true if current led device have multiple color

  • colorIntensities : QHash<String, int>

Can be blank if device not support it

Some device implement led color separatly so it appear separatly with Solid Each key == color Each value == intensity of color

  • set setColorIntensities (QHash<String, int>) : bool

Require +w permission on device_path/multi_intensity

  • rgbSupport : bool

Return true if current led device have multiple color and have red, green, blue color available

  • rgb : QColor

Can be blank if device not support it

Some device implement led color separatly so it appear separatly with Solid

but we can change color for each device with brightness value for each device

  • set rgb (QColor color) : bool

Require +w permission on device_path/multi_intensity

Not implemented:

  • Signal when led brightness is changed (I don't found udev implement for this)

My implementation need unit test ? Or is checked from fakeled ?

Usefull resources

Edited by Florian RICHER

Merge request reports