📜 ⬆️ ⬇️

Weather Forecast Thermometer



With the birth of a child, the attention paid to the weather on the street increases significantly: if you yourself can go outside in what you have to do, and get a little cold or get wet without taking an umbrella, then the parental instinct simply will not allow your child to cause inconvenience. Thanks to modern technology - the temperature outside and the weather forecast can be viewed at any time on special sites (such as pogoda.mail.ru or pogoda.yandex.ru ).

And everything would be fine, but one day I promised my wife to hang a regular thermometer outside the window - she was uncomfortable opening the laptop, going to the site and watching the weather there.
')
As they say in the famous proverb: the man said, the woman recalled, the woman recalled, the woman recalled, the woman zadolbala, - the man did .



In general, the idea of ​​hanging a monitor in the corridor and displaying all kinds of obscenities visited me many times in recent years, but even the smallest 14-inch monitor had nowhere to cram, and small text or graphic displays that all modders love so much, are completely uninformative. and unreadable from afar.

Once, while making an order on the DX website, I came across a fairly small (7 inch) TV with a VGA input and decided to make my idea a reality.



Directly above the entrance door in my apartment there is a small cabinet in which I kept a router, an old laptop used as a server, NAS and other “living creatures”. I bought a TV monitor fit into this zoo perfectly.

The further description is rather trivial, - most can be safely omitted.

Server Tuning



All we need from the computer is to show a web page. The easiest way to do this is to install X, some lightweight window manager, browser and launch it all automatically on launch, opening our page in the browser.

I didn’t suffer with Xs and just installed the latest Ubuntu (April 12, 2012), since it turned out to be LTS, and version 8.04 that I had for all tests and development had long been time to update.

We will give the page using nginx'a:
sudo apt-get install nginx 


And to generate over the crown with the help of Mojolicious - a wonderful framework:
 curl get.mojolicio.us | sudo sh 


In general, it would be possible to give a page using Mojo by running the script (with the slightest alteration) via morbo, but the option with nginx and generating a static file also has a right to exist - so we always give the browser a generated page and we will not have delays Yes, and caching, in the case of multiple clients does not hurt.

Create a directory in which our html-page will be located:
 sudo mkdir -p /var/www/weather/ sudo chown www-data:www-data /var/www/weather 


Save our pearl script:
 sudo curl https://raw.github.com/dreadatour/weather/master/weather.pl -o /usr/bin/generate-weather sudo chmod +x /usr/bin/generate-weather 


Add to crontab a line to run the script. To do this, open the file / etc / crontab in any text editor:
 sudo vim /etc/crontab 


And add the following line to the end:
 * * * * * www-data /usr/bin/generate-weather > /var/www/weather/index.html 


We are waiting for cron to work and we will have a file with the weather forecast (the file will be updated once a minute):
 ls /var/www/weather/index.html 


Edit nginx config / etc / nginx / sites-available / default:
 server { listen 80; server_name localhost; root /var/www/weather/; index index.html; } 

And restart it:
 sudo /etc/init.d/nginx restart 


We check that everything works as it should:
 curl localhost 

(we need to get our html page).

System Setup



As a window manager, the choice fell on Openbox (there was no point in putting heavier WMs). We put it:
 sudo apt-get install openbox 


We set chrome as a browser (or rather its variation - chromium):
 sudo apt-get install chromium-browser 


Put the “unclutter” utility - using it, hide the mouse cursor:
 sudo apt-get install unclutter 


In the settings of ubunt, we enable automatic logon to the system - as it turned out, it is rather inconvenient to climb into the closet after each reboot and log in using the laptop keyboard, and it’s unnecessary and stupid to bring the keyboard out.

Next, create the file /usr/share/xsessions/chrome-session.desktop:
 [Desktop Entry] Name=chrome-session Comment=Weather Exec=/usr/bin/chrome-session 


And the / usr / bin / chrome-session file:
 #!/bin/sh openbox-session & #  openbox xrandr --output VGA1 --mode 800x600 & #    xset s blank & #  screensaver xset s 0 0 & xset -dpms & unclutter -idle 1 & #   chromium-browser --kiosk "http://localhost/" #        


The browser runs in the "kiosk" mode - in full screen mode.

Log out, select our “chrome-session” in the list of sessions, enter the password and get to the page with the weather forecast. Just in case, to check the computer is overloaded:
 sudo reboot 

everything should work.

Do not stop



Together with the TV, I ordered a touch panel of the appropriate size, but when I installed it, I safely ruined everything: due to the curvature of my hands, when the fastening screws were tightened, the panel cracked and refused to work. I have already ordered another panel and the next time I will be neater.
Further plans are to display traffic jams on the monitor (it is convenient to look at them before exiting, simply by poking at the screen), as well as other buns, such as images from a door peephole, various reminders and notifications.

The source code of the script and system configuration files are laid out on the githabe .
An example of how it looks can be found here: weather.dreadatour.ru

Source: https://habr.com/ru/post/144624/


All Articles