Turning Off a Raspberry Pi 5 Screen and Backlight with Debian Bookworm

The Simple Goal

I set out with a simple goal for my Raspberry Pi 5 running Debian Bookworm: have the HDMI-connected screen and its backlight turn off automatically at night, then come back on in the morning. I expected this to be a small display-management task, but it turned into a short tour through Raspberry Pi display drivers.

The Early Stages

Initially, my Raspberry Pi did not have any specific display driver setting enabled in /boot/config.txt. My first attempts used the usual desktop display commands:

  • Using xset: I tried xset dpms force off to blank the screen. It blanked the display output, but the monitor backlight stayed on.
  • Switching to xrandr: Next, I used xrandr --output HDMI-1 --off. This disabled the screen output, but the backlight still remained an issue.

For reference, the active output name can be checked with:

DISPLAY=:0 xrandr --query

On my setup the output was HDMI-1; on another installation it may be named differently.

Exploring Further

I thought ddcutil might provide direct control over the monitor’s power state or brightness settings. In my case, that route was not available because the setup did not expose the required /dev/i2c devices.

A quick check for those devices is:

ls /dev/i2c*

If no matching devices appear, ddcutil will not have a usable I2C bus to talk to the display.

The Driver Discovery

Trying Fake KMS

To address the backlight problem, I enabled the Fake KMS driver in /boot/config.txt:

dtoverlay=vc4-fkms-v3d

After rebooting, this still did not turn off the backlight when the HDMI output was disabled.

Success with Full KMS

The turning point came when I switched to the Full KMS driver instead:

dtoverlay=vc4-kms-v3d

After another reboot, xrandr --output HDMI-1 --off finally controlled not only the displayed image but also the monitor backlight.

The practical sequence was:

  1. Edit /boot/config.txt.
  2. Use dtoverlay=vc4-kms-v3d instead of dtoverlay=vc4-fkms-v3d.
  3. Reboot the Raspberry Pi.
  4. Confirm the output name with DISPLAY=:0 xrandr --query.
  5. Test turning the monitor off and on with xrandr.

The Final Setup

Simplifying Daily Use

To make manual control easier, I added aliases to my .profile:

alias mon='DISPLAY=:0 xrandr --output HDMI-1 --auto'
alias moff='DISPLAY=:0 xrandr --output HDMI-1 --off'

After reloading the shell profile or opening a new login shell, I could use:

moff
mon

Automating the Routine

I set up cron jobs to manage the screen without manual intervention:

# Turn off the monitor in the evening.
0 22 * * * DISPLAY=:0 xrandr --output HDMI-1 --off
0 23 * * * DISPLAY=:0 xrandr --output HDMI-1 --off
0 0 * * * DISPLAY=:0 xrandr --output HDMI-1 --off

# Turn on the monitor in the morning.
0 8 * * * DISPLAY=:0 xrandr --output HDMI-1 --auto

The repeated evening entries are deliberate: they make the off command run again later in case the display was woken manually or by another process. Also note that cron uses 0 0 for midnight; 0 24 is not valid cron syntax on typical systems.

In Conclusion

This was more than a simple display toggle. On my Raspberry Pi 5 with Debian Bookworm, the key was switching from Fake KMS to Full KMS. Once dtoverlay=vc4-kms-v3d was active, xrandr could turn off both the HDMI output and the monitor backlight, making the nightly automation work as intended.

Leave a Reply