As this is wayland (it's just a protocol), this will depend on your compositor (e.g. Kwin for KDE, Mutter for GNOME), but it does not seem like there is anything equivalent as of right now (February 2023).
I dug into the code to learn how xrandr actually does this, and the relevant code is right here: https://gitlab.freedesktop.org/xorg/app/xrandr/-/blob/6f714830da6c8d74f024be6b0bb32c1ea39c1217/xrandr.c#L1469-1494
Here's the relevant snippet:
if (output->gamma.red == 0.0)
output->gamma.red = 1.0;
if (output->gamma.green == 0.0)
output->gamma.green = 1.0;
if (output->gamma.blue == 0.0)
output->gamma.blue = 1.0;
gammaRed = 1.0 / output->gamma.red;
gammaGreen = 1.0 / output->gamma.green;
gammaBlue = 1.0 / output->gamma.blue;
for (i = 0; i < size; i++) {
if (gammaRed == 1.0 && output->brightness == 1.0)
crtc_gamma->red[i] = (double)i / (double)(size - 1) * 65535.0;
else
crtc_gamma->red[i] = dmin(pow((double)i/(double)(size - 1),
gammaRed) * output->brightness,
1.0) * 65535.0;
if (gammaGreen == 1.0 && output->brightness == 1.0)
crtc_gamma->green[i] = (double)i / (double)(size - 1) * 65535.0;
else
crtc_gamma->green[i] = dmin(pow((double)i/(double)(size - 1),
gammaGreen) * output->brightness,
1.0) * 65535.0;
if (gammaBlue == 1.0 && output->brightness == 1.0)
crtc_gamma->blue[i] = (double)i / (double)(size - 1) * 65535.0;
else
crtc_gamma->blue[i] = dmin(pow((double)i/(double)(size - 1),
gammaBlue) * output->brightness,
1.0) * 65535.0;
}
XRRSetCrtcGamma(dpy, crtc->crtc.xid, crtc_gamma);
What xrandr does to reduce the brightness is actually change the gamma function to ramp up slower up to a max value, by applying a gamma curve to the RGB channels, and applying it using XRRSetCrtcGamma
-- short for XRANDR Set CRTC Gamma, where XRANDR is X.org Resize and Rotate, and CRTC is a CRT (cathode ray tube) controller, which despite the old name, is just a term for the video controller in general.
As this behaviour is specific to xrandr, compositors themselves (e.g Kwin or Sway) will have to implement it, but before even that, I believe wayland needs to implement the protocol.
So it will require
- The wayland protocol to be agreed upon and merged (there's a PR here that I can see: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/14)
- Your compositor (kwin, mutter, sway, weston, etc) to implement this protocol
- Your compositor to expose the gamma changing settings in an API
- Someone to write a tool, like xrandr, that adjusts the brightness using a gamma curve, using this new API. This could also, in theory, be done by your compositor, which can expose a CLI or a graphical interface to adjust this.
xrandr
itself has been replaced by compositor-specific tools like kscreen-doctor
and the GUI system settings for your desktop environment, so it will be up to your desktop environment to provide tools to do exactly what xrandr --brightness
has done in the past.
EDIT: further looking into the kwin code, it appears that if your compositor supports night color (aka redshift) of some sort, it should in theory be possible to support this.
Kwin actually has support for brightness in the code, but it doesn't appear to be exposed by any of the built-in plugins, but it seems like it's possible to write a plugin that changes the brightness.
/sys/class/backlight
or using Gnome DBus interfacedbus-send --type=method_call --dest=org.gnome.SettingsDaemon /org/gnome/SettingsDaemon/Power org.freedesktop.DBus.Properties.Set string:'org.gnome.SettingsDaemon.Power.Screen' string:'Brightness' variant:int32:30
source seems old you may find updated ones here in AskUbuntu. – user.dz Oct 24 '20 at 09:55/sys/class/backlight
won't work on desktop. I am not sure what GNOME DBus interface does. It probably won't work outside GNOME. xrandr works on every major DE – Archisman Panigrahi Oct 24 '20 at 10:44/sys/class/backlight
as here https://askubuntu.com/a/785335/26246 because that the basic low level control if it is not there then probably have driver issue. doc: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/stable/sysfs-class-backlight . For DBus, Yeah it is only for Gnome & Unity. – user.dz Oct 24 '20 at 10:58dark night mode
in chrome. i'm sure it works with wayland – Алексей Неудачин Dec 17 '21 at 15:58