Having some spare monitor’s laying around (from the dumpster), I did already make some nice projects with them. In the Dual photo webpage with Angular project I added some nice tvservice magic.
I thought it was worth having its own place.
This project is nothing more than a webpage (not even a page, more a web command listener) to turn the connected HDMI monitor on and off.
Turning the monitor on and off
With the use of the tvservice command, we can just remove the HDMI signal. The monitor will then go to sleep, waiting for the HDMI signal to come back on.
All the code can be found on my github: https://github.com/timdows/RaspberrypiWebTvservice
It creates three get endpoints:
Every endpoint makes sure the display goes ON/OFF or ON on a timer.
By default, the express server listens on port 3000.
Configure express server to host the webpage
I picked express server for nodejs to host the webpage.
If you are running on a ARMv6 environment (Raspberry Pi Zero W), you will needed some custom installation instructions to get node and npm installed. Luckily there is an easy installation https://github.com/sdesalas/node-pi-zero.
To use the application execute the following commands:
git clone https://github.com/timdows/RaspberrypiWebTvservice
It is then as easy as running it:
Startup on boot
I use pm2 for this. The executable script looks like this: