3

I can simply change my monitor brightness via

xrandr --output VGA1 --brightness 0.25

Though it is software-only modification, it does the trick anyway. According to the man page, xrandr is the primitive command line interface to RandR extension, so it is quiet possible to change my monitor brightness programmatically. However, I didn't find any related API in its header file <X11/extensions/Xrandr.h>.

How to change the monitor brightness by X11 RandR extension library in C?

Kevin Dong
  • 5,001
  • 9
  • 29
  • 62

1 Answers1

2

yes, xrandr extension, RRChangeOutputProperty request. With libXrandr it's XRRChangeOutputProperty function. See usage example example in xbacklight source

Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75
  • 3
    According to the [man page](http://manpages.ubuntu.com/manpages/precise/man1/xrandr.1.html), `xbacklight` and `xrandr --brightness` are totally different. `xblacklight` controls hardware brightness if possible, but `xrandr` doesn't. – Kevin Dong Jan 15 '15 at 05:08
  • which one do you need? both gamma and backlight changed via randr extension calls – Andrey Sidorov Jan 15 '15 at 09:35
  • Both gamma and backlight changed is okay, but I want to know how `xrandr` implements for brightness. `xblacklight` doesn't affect my monitor brightness, but `xrandr` does. – Kevin Dong Jan 15 '15 at 10:18
  • [Xblacklight](https://gitlab.freedesktop.org/xorg/app/xbacklight/blob/xbacklight-1.2.2/xbacklight.c#L113) (same also for `xrandr --set backlight`) likely doesn't affect your monitor because not every xf86-video driver supports its RandR's [backlight](https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt?h=randrproto-1.5.0#n1905) property. `Xrandr`[`--brightness`](https://gitlab.freedesktop.org/xorg/app/xrandr/blob/xrandr-1.5.0/xrandr.c#L1105) is instead just working "in software" with gamma and colours *internally* to the server, and that's why it always appear to work. – mirh Jun 23 '19 at 14:01
  • The brightness is never exposed via XRandR extensions, it might be possible to change this via the CTM output property (Color Transform Matrix) by using a reduced identity matrix to achieve a brightness reduction in all colors but CTM is an "immutable" output property for my driver, maybe newer GPU drivers support it. – Motomotes Mar 31 '23 at 00:07