Display backlight control

I’m having trouble with what to do with my Reform when I’m not using it. Suspend is too unreliable for now (see Investigate Sleep/Hibernate/Wake (#8) · Issues · Reform / reform · GitLab) so I’ve installed xfce4-screensaver which blanks the screen when idle. Unfortunately it does not turn off the display backlight.

Has anyone found a manual way to control the display backlight? I don’t even really need it to be triggered on idle; I could just bind one key to enable it and one to disable it and it would still be a big improvement over what I’m doing now.

The backlight is controllable via /sys/class/backlight/backlight/brightness with valid values being 0 (off) to 6 (fully on).

You can either write to the file directly or use tools like brightnessctl to set the brightness.

Turn off screen:

$ brightnessctl s 0
Updated device 'backlight':
Device 'backlight' of class 'backlight':
	Current brightness: 0 (0%)
	Max brightness: 6

Or:

echo 0 > /sys/class/backlight/backlight/brightness

To turn it back on, write a value between 1 and 6 instead.

If you can execute commands as root, you can also use bl_power:

# echo 4 > /sys/class/backlight/backlight/bl_power # Turn off
# echo 0 > /sys/class/backlight/backlight/bl_power # Turn back on

See Backlight support — The Linux Kernel documentation for more details.

1 Like

You can use swayidle to do it for you, but I’d imaging xfce4 to be doing the same thing.
Assuming you use sway - what happens if you do swaymsg "output * dpms off" - does it turn backlight off or just dims the brightness to 0?

1 Like

I just tested this, and it sets /sys/class/backlight/backlight/bl_power to 4. It does not change the brightness.

It also does something else as writing 0 to bl_power doesn’t turn the backlight back on. Keyboard input or moving the mouse cursor doesn’t either, but swaymsg "output * dpms on works.

I don’t have Xorg installed anymore, but I remember xset dpms force off doing something similar, but moving the mouse or key input would turn the screen back on.

That’s where swayidle comes to picture:

$ grep idle ~/.config/sway/config 
# make sure to add -f to lock otherwise it won't release the idle pipeline till unlocked
exec_always --no-startup-id swayidle -w timeout 600 'swaylock -fei /usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg' timeout 300 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -fei /usr/share/backgrounds/cosmos/galaxy-ngc3370.jpg'

I don’t have Xorg installed anymore, but I remember xset dpms force off doing something similar

Unfortunately this gives “server does not have extension for dpms option”

Similarly, xfce4-screensaver when it blanks the screen gives this output: Xlib: extension “DPMS” missing on display “:0”

But that’s OK; being able to manually blank the screen with brightnessctl is good enough for now. Thanks!

BTW, slightly hidden, but this is mentioned in the handbook: Graphical Desktops — MNT Reform Operator Handbook documentation

2 Likes