.. title: Weather widget
.. slug: weather-widget
.. date: 2019-01-27 14:56:42 UTC
.. tags: desktop
.. category: 
.. link: 
.. description: 
.. type: text

To my great dismay, Yahoo `announced <https://developer.yahoo.com/weather/>`_ earlier this year that their weather API will retire at January 3rd. And indeed, my `little weather conky <https://cobra.pdes-net.org/posts/conkys-resurrection.html>`_ ceased to work at this day and thus reached its EOL. 😞 

That's really too bad. Common forecast sites are peppered with dozens of javascripts and take ages to open on my Mini or my Lifebook. Here's `an example <https://www.wunderground.com/forecast/de/berlin/IBERLIN1658?cm_ven=localwx_10day>`_ which I find disagreeably slow even on my desktop. Besides, I also liked my weather conky for its `aesthetic merit <https://cobra.pdes-net.org/posts/weather.html>`_ – at least _I_ found it pleasing to look at. 

Well well well. There’s no point in crying over spilled milk. What are the options? There's `conkywx, <https://bitbucket.org/plikhari/conkywx_pub/wiki/Home>`_ of course, the script collection for true weather aficionados. I  look at it every second year and always feel that it's a tad overwhelming, at least  for me, both with regard to features and visuals (`one <http://users.gilanet.com/~tfrost/brrr-12-16-15>`_, `two <https://imgur.com/OE2lSUR>`_, `three <https://browse.startpage.com/do/show_picture.pl?l=english&rais=1&oiu=http%3A%2F%2Fi67.tinypic.com%2Fbdv19s.png&sp=432e1c38d274c717c0c885f317b0dd9f&t=default>`_).  

Alternatively, I could rebuild my weather conky around a new API – perhaps even the new Yahoo API. But I don't like to register anywhere for a simple weather forecast (and certainly not at Yahoo), and also don't want to spent more than, say, 15 min in getting a new forecast. 

And then I found `wttr.in <http://wttr.in>`_ – the fastest weather forecast ever. It's accessible by browser or in the terminal as a curl-based service, can be configured on the fly, and its ASCII graphs breath nerdy charm. 

It's a one-liner in conky:

::

	${execpi 3600 curl -s "wttr.in/Berlin?nT&lang=de" | head -n -2}

for a narrow (?n) and black-and-white (?T) view and 

::

	${execpi 3600 curl -s "wttr.in/Berlin?n&lang=de" | ~/.config/conky/ansito | head -n -2}

in full color thanks to `ansito, <https://github.com/pawamoy/ansito>`_ which translates the ANSI color codes to the corresponding ones on conky. 

But do we actually need a desktop widget when the forecast is so readily accessible? One could simple have an extra tab open in a browser, for example. Or, one could have a tab reserved for wttr.in in a `Guake <http://guake-project.org/>`_ style terminal. For convenience, one could define an alias (works for all major shells) that updates the weather forecast every hour:

.. code:: bash

	alias wttr='watch -ct -n 3600 "curl -s wttr.in/Berlin?lang=de | head -n -2"'

Hey, I like that. 😊
