Posts: 71
Joined: Wed Jul 06, 2016 1:36 pm

Fixed display power management

Fri Aug 31, 2018 4:50 pm

Due to Raspberry Pi's peculiarity, default linux DPMS doesn't turn the screen off after idle time, it only fills it with a dark color.
That is solved when using the unfinished OpenGL driver. But that isn't the only way!

Minimal C code

Code: Select all

#include <X11/extensions/scrnsaver.h>
#include <stdio.h>

int main(void) {
    Display *dpy = XOpenDisplay(NULL);

    if (!dpy) {

    XScreenSaverInfo *info = XScreenSaverAllocInfo();
    XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
    printf("%u\n", info->idle);

And a script to make it all work

Code: Select all

while true; do
              if [[ $idle = false && $idleTimeMillis -gt $idleAfter ]] ; then
                              vcgencmd display_power 0

	if [[ $idle = true && $idleTimeMillis -lt $idleAfter ]] ; then
		vcgencmd display_power 1
                sleep 4      # polling interval

Source of information

I hope something like this gets into Raspbian.

Posts: 7428
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Fixed display power management

Sat Sep 01, 2018 1:19 am

Adding this to /boot/config.txt will automatically turn off video output on blanking timeout.

Code: Select all

On blanking my TV will show no signal message for about 20 min then turn off. Once the screen has gone off it won't wake up again unless I press the ON button. While the no signal message is displayed the RPi screen will wake up as expected.

I also get the same behavior when using vcgencmd display_power 0 from command line.... After the 20 min screen off, issuing vcgencmd display_power 1 will not turn on the display without also pressing the power ON button. (Tested by VNC connection).
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

Return to “Raspberry Pi OS”