Use this open source tool to get your local weather forecast

Know whether you need a coat, an umbrella, or sunscreen before you go out with wego in the thirteenth in our series on 20 ways to be more productive with open source in 2020.
128 readers like this
128 readers like this
Sky with clouds and grass

Flickr user: theaucitron (CC BY-SA 2.0)

Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.

Check the weather with wego

One of the things I love about the past decade of my employment is that it mostly has been remote. I can work anywhere I happen to be in the world, although the reality is that I spend a lot of time in my home office. The downside is that when I leave the house, I base a lot of decisions on what the conditions look like outside my window. And where I live, "sunny and clear" can mean anything from "scorchingly hot" to "below freezing" to "it will rain in an hour." Being able to check the actual conditions and forecast quickly is pretty useful.

Wego

Wego is a program written in Go that will fetch and display your local weather. It even renders it in shiny ASCII art if you wish.

To install wego, you need to make sure Go is installed on your system. After that, you can fetch the latest version with the go get command. You'll probably want to add the ~/go/bin directory to your path as well:

go get -u github.com/schachmat/wego
export PATH=~/go/bin:$PATH
wego

On its first run, wego will complain about missing API keys. Now you need to decide on a backend. The default backend is for Forecast.io, which is part of Dark Sky. Wego also supports OpenWeatherMap and WorldWeatherOnline. I prefer OpenWeatherMap, so that's what I'll show you how to set up here.

You'll need to register for an API key with OpenWeatherMap. Registration is free, although the free API key has a limit on how many queries you can make in a day; this should be fine for an average user. Once you have your API key, put it into the ~/.wegorc file. Now is also a good time to fill in your location, language, and whether you use metric, imperial (US/UK), metric-ms, or International System of Units (SI). OpenWeatherMap supports locations by name, postal code, coordinates, and ID, which is one of the reasons I like it.

# wego configuration for OEM
aat-coords=false
aat-monochrome=false
backend=openweathermap
days=3
forecast-lang=en
frontend=ascii-art-table
jsn-no-indent=false
location=Pittsboro
owm-api-key=XXXXXXXXXXXXXXXXXXXXX
owm-debug=false
owm-lang=en
units=imperial

Now, running wego at the command line will show the local weather for the next three days.

Wego can also show data as JSON output for consumption by programs and with emoji. You can choose a frontend with the -f command-line parameter or in the .wegorc file.

Wego at login

If you want to see the weather every time you open a new shell or log into a host, simply add wego to your ~/.bashrc (or ~/.zshrc in my case).

The wttr.in project is a web-based wrapper around wego. It provides some additional display options and is available on the website of the same name. One cool thing about wttr.in is that you can fetch one-line information about the weather with curl. I have a little shell function called get_wttr that fetches the current forecast in a shortened form.

get_wttr() {
  curl -s "wttr.in/Pittsboro?format=3"    
}

weather tool for productivity

Now, before I leave the house, I have a quick and easy way to find out if I need a coat, an umbrella, or sunscreen—directly from the command line where I spend most of my time.

What to read next
Tags
Kevin Sonney is a technology professional, media producer, and podcaster. A Linux Sysadmin and Open Source advocate, Kevin has over 25 years in the IT industry, with over 15 years in Open Source. He currently works as an SRE at elastic.

3 Comments

For a simple, text-based feedback about the weather, I like 'weather' - obtainable at http://fungi.yuggoth.org/weather/src/. The current weather report looks like this:
Searching via name...
[using result Louisville East CCD, KY]
Current conditions at Bowman Field, KY
Last updated Jan 23, 2020 - 08:53 AM EST / 2020.01.23 1353 UTC
Temperature: 39.0 F (3.9 C)
Relative Humidity: 42%
Wind: from the SE (130 degrees) at 6 MPH (5 KT)
Sky conditions: overcast
and the forecast like this:
***** Zone Forecast *****
Expires:202001232115;;380630
FPUS53 KLMK 230837
ZFPLMK
Zone Forecast Product for Southern Indiana and Central Kentucky
National Weather Service Louisville KY
337 AM EST Thu Jan 23 2020
KYZ030-232115-
Jefferson-
Including the city of Louisville
337 AM EST Thu Jan 23 2020
.TODAY...Cloudy. Rain likely in the afternoon. Highs in the upper
40s. Southeast winds up to 10 mph. Chance of rain 70 percent.
.TONIGHT...Rain. Near steady temperature in the lower 40s.
Southeast winds 5 to 10 mph. Chance of rain near 100 percent.
.FRIDAY...Rain. Highs in the mid 40s. South winds 5 to 10 mph.
Chance of rain near 100 percent.
.FRIDAY NIGHT...Cloudy with a 50 percent chance of rain. Lows in
the mid 30s. Southwest winds 5 to 10 mph.
.SATURDAY...Cloudy with a 40 percent chance of rain. Highs around
40. West winds 5 to 10 mph with gusts to around 25 mph.
.SATURDAY NIGHT...Cloudy. Lows in the lower 30s.
.SUNDAY...Mostly cloudy. Highs in the lower 40s.
.SUNDAY NIGHT...Mostly cloudy. Lows in the lower 30s.
.MONDAY...Mostly cloudy. Highs in the mid 40s.
.MONDAY NIGHT...Partly cloudy. Lows in the lower 30s.
.TUESDAY...Partly cloudy. Highs in the upper 40s.
.TUESDAY NIGHT...Mostly cloudy. Lows in the upper 30s.
.WEDNESDAY...Cloudy with a 20 percent chance of rain. Highs in
the lower 50s.
According to the README, it can be obtained for Ubuntu and Debian as weather-util.

Weather

Great article, these kinds of tools are very cool!

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.