How to turn the monitor connected to your RaspberryPi on and off with a shell script

You may be working on an application that uses the monitor connected to your RaspeberryPi, but you want to be able to turn the monitor off and on during certain times of day. The following shell script does that for you.

Save the script in an appropriate directory, e.g. call it ‘display_ctrl’. To turn the monitor off, write the following command in the shell when in the directory that the script is located:

./display_ctrl Off

To turn the display on:

./display_ctrl On

To call the script from Python use the following line: