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.
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
.
-
1This 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 Mar 1 '19 at 7:24
-
@Chadi Running repeatedly might be better if, for example, the device was turned off at 7 am. – daiscog Apr 10 '19 at 10:12
-
1
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.
-
-
1
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
-
Good find. This should really be a comment to the answer you refer to, but I know you can't post comments yet. – Dmitry Grigoryev Jan 18 '19 at 9:28
-
thats my problem, feel free to add the comment to the accepted answer or suggest an edit :) – André Düwel Jan 18 '19 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 theon
, also worked but after a while the display turned off again. Second time executedon
command and again display turned off after a while. Don't realize why – dstonek May 28 '19 at 13:23