linuxmint / cinnamon-settings-daemon

The settings daemon for the Cinnamon desktop
GNU General Public License v2.0
57 stars 58 forks source link

org.cinnamon.SettingsDaemon.Power.Screen.SetPercentage sets wrong value #348

Open navid-zamani opened 2 years ago

navid-zamani commented 2 years ago
 * csd version:  5.0.4+uma
 * Distribution: Linux Mint 20.2 Uma
 * Graphics hardware *and* driver used: Intel(R) HD Graphics 3000 (SNB GT2), using i915 driver
 * 32 or 64 bit: 64 bit

Issue It does not set the actual percentage that it is given. E.g. for pIn=33, SetPercentage reports (uint32 33,), but actually, as GetPercentage confirms, it is set to (uint32, 26,) for some reason! And 66 results in 60. For those two values, pIn=$(( pIn+1 )) is a hack to make it work. But values in-between, like from 67 to 72, can not be set at all! (Setting it to 74 lets you set it to 73 again.)

Steps to reproduce

read pIn
gdbus call --session --dest org.cinnamon.SettingsDaemon.Power.Screen --object-path /org/cinnamon/SettingsDaemon/Power --method org.cinnamon.SettingsDaemon.Power.Screen.SetPercentage $pIn
pOut=$( gdbus call --session --dest org.cinnamon.SettingsDaemon.Power.Screen --object-path /org/cinnamon/SettingsDaemon/Power --method org.cinnamon.SettingsDaemon.Power.Screen.GetPercentage )
[[ $pOut == $pIn ]] && echo "Worked as expected" || echo "Failed"

Expected behaviour Outputs “Worked as expected”, for all pIn values from 0 to 100. Ideally when using floating point values too.

Other information This granularity also exists for the UI controls (Fn-Brighter and Fn-Darker key combos). But it does not exist for setting /sys/class/backlight/intel_backlight/brightness directly! There, any value between 0 and $(</sys/class/backlight/intel_backlight/max_brightness) is possible and works. BUT: Cinnamon doesn't notice and e.g. after power save, resets the brightness to what it knows again. Also, very weirdly, the mapping from Cinnamon's to the sysfs one is NOT linear. Which makes mattes even worse, since a script, like a hook for redshift, cannot properly set e.g. 50% brightness, and Cinnamon just plain doesn't “allow” it. And I can't find any settings to change the granularity or mapping function.