How to change xrandr brightness without losing gamma settings?

KDE's Night Color feature I guess uses xrandr's gamma functionality, but I was hoping to adjust the brightness of my display using it. Unfortunately, doing so like this loses the "night color" because it resets the gamma:

xrandr --output DP-0 --brightness .8

Is there some way to query the currently applied values from xrandr so I can reapply them?


Solution 1:

To change brightness independently of xrandr:

From my tests on my stock Ubuntu 20.04 system, it seems the input and output of the xgamma tool are completely independent to xrandr. So, if you change the brightness using xgamma -gamma 0.8 then that shouldn't affect the xrandr night light settings :)


To query the currently applied gamma values of xrandr:

xrandr --verbose | grep "Gamma"

I had a look at man xrandr for documentation, and it seems the --verbose flag gives out the details for the gamma.

It does say

Please note that the gamma and brightness informations are only approximations of the complete color profile stored in the server.

and my tests seem to show that the value output by this is not the same as what is passed during input.

For example, if I enter xrandr --output eDP-1 --gamma 2:0.5:0.2 and then xrandr --verbose | grep "Gamma", it outputs:

    Gamma:      0.50:2.0:5.0

I closed Redshift before running these tests, so hopefully that didn't interfere.

There might be some way to figure out a transformation to interpret the value, but I am not sure about that.