Tichun
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) {
        return(1);
    }

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

        return(0);
}
And a script to make it all work

Code: Select all

#!/bin/bash
idle=false
idleAfter=480000
while true; do
          idleTimeMillis=$(./getIdle)
              if [[ $idle = false && $idleTimeMillis -gt $idleAfter ]] ; then
                              idle=true
                              vcgencmd display_power 0
                fi

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

Source of information

I hope something like this gets into Raspbian.

klricks
Posts: 7436
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

hdmi_blanking=1
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”