pop-os / cosmic-settings-daemon

GNU General Public License v3.0
20 stars 16 forks source link

Expose brightness as percent in BrightnessDevice #32

Closed mttmartin closed 2 months ago

mttmartin commented 2 months ago

Currently BrightnessDevice operates with the raw values from sysfs and exposes them to other components via zbus. This can lead to some unexpected behaviour (e.g. when read from cosmic-osd), since the brightness values are not normalised by the maximum brightness there. This was reported in an issue here: https://github.com/pop-os/cosmic-applets/issues/484

This PR modifies BrightnessDevice so that it exposes brightness in percent to the outside, so any caller does not have to take into account the maximum brightness and normalise the value themselves.

ids1024 commented 2 months ago

https://github.com/pop-os/cosmic-settings-daemon/pull/33 added the max percentage. This requires a bit more work from the client, as you say, instead of converting here. But also allows something like the slider in cosmic-applet-battery to know what the max brightness and step size is (used in https://github.com/pop-os/cosmic-applets/pull/492).

We still want to consider changes to the brightness interface in the future, particular if we want to support multiple/external brightness devices (https://github.com/pop-os/cosmic-applets/issues/428), but I think we don't need this particular API for the time being.