Adding weather information in conky
I discovered a neat trick to put weather information in the super versatile conky system monitor. This might be just sheer laziness, but the results turned out to be quite nice and unobtrusive, so I'm sharing how to do it here even for my own future reference, too.
To start off, a really lightweight way to receive weather information is to use Igor Chubin's minimalistic wttr.in service, which you can even do it from the terminal, like this:
$ curl wttr.in
Not only this service is pretty cool, but it's even more useful than it looks because there's also an API behind it that allows you to receive just specific data to put in a summary. So let's say you just want to see the conditions and temperature right this moment. You could use a query like this:
$ curl "https://wttr.in/?format=Condition:+%C\nTemperature:+%t\n"
Condition: Sunny
Temperature: +37°C
Thus we can then tailor the query to just receive exactly what we want in a plain text, newline-delimited format that conky could work with. There are many variables you can fetch via that API, but here's my query for example:
curl https://wttr.in/?format=Condition:+%C\nTemperature:+%t\nHumidity:+%h\nWind:+%w\nPrecipitation:+%p\n"
If all the information you need is in there, you can wrap everything up by adding this statement (together with curl
) to a timed execution block of conky and give it an interval for repetition in seconds. Then add it to your conky.text
block somewhere:
${execi 900 curl https://wttr.in/?format="Condition:+%C\n""Temperature:+%t\n""Humidity:+%h\n""Wind:+%w\n""Precipitation:+%p\n"}
Where 900 seconds runs it once every 15 minutes. The adding of quotes is indeed a little tricky, but follow the template and it works.
Lastly, if the location being picked up for you by this query is a little off (perhaps because of how your public IP is set), you can still fine-tune it by adding your location or city right after the slash:
$ curl https://wttr.in/Bratislava
And that's it! Enjoy automatic weather information without even opening typing anything!
Credit where this trick is due: this great thread in the Devuan forums contains these instructions plus a big list of all variables you can fetch via wttr.in's API.