7

I have my Raspbian running Chromium in kiosk mode and works nicely. However, I would like it to turn the HDMI display off at 10pm and wake it up at 7am. I could not find such a setting in Raspbian.

3 Answers 3

9

I am using xset dpms force off to turn off the display. This command uses Display Power Management Signaling.

In a cron job, you'll need to set the DISPLAY variable, so that the crontab entries become something like:

0   22  *   *   *   DISPLAY=:0 xset dpms force off
0   7   *   *   *   DISPLAY=:0 xset dpms force on

Make sure the X server is started with -dpms.

5
  • 1
    This will run every minute of 22h and 7h. @andré-düwel's answer configures the cronjob to run at 22:00 and 7:00 and better answers the original question.
    – Chadi
    Commented Mar 1, 2019 at 7:24
  • @Chadi Running repeatedly might be better if, for example, the device was turned off at 7 am.
    – daiscog
    Commented Apr 10, 2019 at 10:12
  • 1
    Good catch. I fixed it above. Thanks, @André-Düwel and Chadi! Commented Feb 19, 2020 at 7:18
  • this worked when other suggestions for cec-util and tvresource failed to work (Raspberry Pi 4B) failed to work
    – Fred
    Commented Aug 13, 2023 at 19:30
  • How does one "make sure the X server is started with -dpms"? I am running a Pi4 with stock Raspian.
    – cdeerinck
    Commented Oct 10, 2023 at 16:55
5

You may want to look into HDMI CEC which allows you to send commands such as power on/off via HDMI to a TV set. There's a libcec for this, as well as an cec-client. For instance, this blog post about switching on/off a TV may help: https://timleland.com/raspberry-pi-turn-tv-onoff-cec/

Then set up a cron job to run cec-client in the evening and the morning.

2
  • Unfortunately I am using a monitor which is not CEC compatible.
    – Kashif
    Commented Jun 6, 2017 at 2:34
  • 1
    Maybe you should add relevant commands to your answer. Commented Jan 18, 2019 at 9:38
4

Like Steffen Uhlig wrote, using xset dpms force [on|off] is the solution for normal displays. Please note that his cronjob is running every minute in the specified hour.

crontab -e (as normal pi user) will allow you to add a cronjob, where you just need to add the following lines at the end:

0   22  *   *   *   DISPLAY=:0 xset dpms force off
0   7   *   *   *   DISPLAY=:0 xset dpms force on
3
  • Good find. This should really be a comment to the answer you refer to, but I know you can't post comments yet. Commented Jan 18, 2019 at 9:28
  • thats my problem, feel free to add the comment to the accepted answer or suggest an edit :) Commented Jan 18, 2019 at 16:46
  • I added that to my cron: off at 22 and on at 07. To make a try, from command line I executed the off command, it worked. Then I executed the on, also worked but after a while the display turned off again. Second time executed on command and again display turned off after a while. Don't realize why
    – dstonek
    Commented May 28, 2019 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.