Inspired by this article, I’ve decided to create a new clock for my living room.
The full code is available on GitHub.
Normally, it’ll show the time and weather forecast for the following 24 hours:
Setting the Pi up
The first thing to do is to install Raspbian on the Pi: simply follow the instructions on the official site (I’ve used Etcher, as it seemed the easiest way to do it).
Before moving the SD card into the Rasperry Pi, you might want to create an empty file named ssh in the root of the card: it will enable ssh at the first boot, making it easier to proceed if you don’t have a keyboard to connect to the Pi.
If you’re using the display in a case like the one from OneNineDesign, you’ll also need to add this line to config.txt:
Since we need a reliable clock, install chrony to keep the time synchronized with NTP servers:
Booting into the application
From now on, I’ll assume you’re connect to the Pi via ssh. You can find out the ip to use in several different ways: looking at the DHCP leases on your DHCP server/router, using ifconfig in a terminal, etc…
Execute sudo raspi-config and set the Pi to boot to the Desktop, with autologin.
Let’s make sure that there won’t be a visible mouse pointer on the screen. Edit /etc/lightdm/lightdm.conf and look for the line with “xserver-command”. Either uncomment and edit it, or add a new line afterwards:
xserver-command=X -bs -core -nocursor
Create /home/pi/.xinitrc with the following content:
while true; do
killall -9 chromium-browser 2>/dev/null
# Disable DPMS / Screen blanking
xset s off
# start without using cache or writing to disk
chromium-browser --app=http://url.to.your.clock.setup/ --incognito --disk-cache-dir=/dev/null
url.to.your.clock.setup needs to be the address of the site running the code cloned from GitHub, obviously. 🙂 It can be a different machine, or the very same Raspberry Pi, if you install apache + php on it. Follow the instructions in the readme to configure the web app.
Finally, create a link too:
so that the script will be executed either when X gets started by the display manager or startx.
Now reboot, and if everything went ok, you’ll see your new clock 🙂
One last thing… if you find that the display is too bright, you can adjust the brightness with the command:
with 32 being a number between 0 and 255.
Once you find the level you like, add that command to /etc/rc.local