How to check weather forecasts from the command line on Linux

Last updated on August 20, 2020 by Dan Nanni

Question: I often check local weather forecasts on the Linux desktop. However, is there an easy way to access weather forecast information in the terminal environment, where I don't have access to desktop widgets or web browser?

For Linux desktop users, there are many ways to access weather forecasts, e.g., using standalone weather apps, desktop widgets, or panel applets. If your work environment is terminal-based, there are also several ways to access weather forecasts from the command line.

Among them is wego, a cute little weather app for the terminal. Using an ncurses-based fancy interface, this command-line app allows you to see current weather conditions and forecasts at a glance. It retrieves the weather forecasts for the next 5 days via a weather forecast API.

Install wego on Linux

Installation of wego is pretty simple. wego is written in Go language, thus the first step is to install Go language. After installing Go, proceed to install wego as follows.

$ go get github.com/schachmat/wego

The wego tool will be installed under $GOPATH/bin. So add $GOPATH/bin to your $PATH variable.

$ echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.bashrc
$ source ~/.bashrc

Now go ahead and invoke wego from the command line.

$ wego

The first time you run wego, it will generate a config file (~/.wegorc), where you need to specify a weather API key.

Obtain an API Key for Weather Forecast Information

wego fetches weather forcast information from an external online service via weather forecast API, and for that you need to get an API key.

To obtain a free API key, go to OpenWeather, and sign up for API acces. Sign-up is quick and easy. You only need a valid email address.

Your .wegorc will look like the following.

Other than API key, you can specify in ~/.wegorc your preferred location, use of metric/imperial units, and language.

Note that the weather API provided by OpenWeather is rate-limited; 60 queries per minute, and 1M queries per month.

When you invoke wego command again, you will see the latest weather forecast (of your preferred location), shown as follows.

The displayed weather information includes: (1) temperature, (2) wind direction and speed, (3) viewing distance, and (4) precipitation amount and probability.

By default, it will show 3-day weather forecast. To change this behavior, you can supply the number of days (upto five) as an argument. For example, to see 5-day forecast:

$ wego 5

If you want to check the weather of any other location, you can specify the city name.

$ wego Seattle

Troubleshooting

1. You encounter the following error while running wego.

user: Current not implemented on linux/amd64

This error can happen when you run wego on a platform which is not supported by the native Go compiler gc (e.g., Fedora). In that case, you can compile the program using gccgo, a compiler-frontend for Go language. This can be done as follows.

$ sudo yum install gcc-go
$ go get -compiler=gccgo github.com/schachmat/wego

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean