ASCII weather app for the terminal

Days of Thunder

Article from Issue 187/2016
Author(s):

Other applications have found less complex ways of showing the weather in a terminal, but none is as attractive as Wego.

People love to check out the weather forecast, but some users prefer to avoid the many web-based services, where you first need to search for the forecast amid all the advertising or switch to the desktop and face the weather through a Plasmoid or Conky widget. Users who always have a terminal open will appreciate the attractive Wego option for presenting the weather in a command-line window.

The Wego weather app [1], written in the Go programming language designed by Google, uses ASCII art to display the weather forecast for the next one to five days. In this case, using the terminal does not mean poor visuals or a lack of functionality. In this article, I'll take a closer look at Wego and briefly investigate the alternatives.

Weather Forecast

Wego delivers information on the temperature range, wind speed and direction, visibility, and the likelihood and amount of precipitation (Figure 1) for up to five days in advance. The information is SSL-encrypted for transmission to the local computer.

Figure 1: Wego presents a simple and readable weather forecast.

The requirements for installation are quickly met. If you've not done so already, you need to set up Git and a Go environment and also register on the weather website at forecast.io. You can pick up a free API key from the site that lets Wego retrieve the raw weather data. The terminal you are using must support 256 colors and UTF-8. Most terminals meet these requirements out of the box, although you may have to adapt the settings by right-clicking on the open terminal in the profile. You can experiment with the font type and size until the Wego output is to your liking.

Preparations

First, install Go and Git for your distribution. On Debian and its derivatives, you can do this with the command from the first line of Listing 1. On Fedora, the corresponding command is, for example:

dnf install golang git

Listing 1

Go Environment Setup

01 $ sudo apt-get update && sudo apt-get install golang git
02 $ echo 'export GOPATH="$HOME/wego"' >> ~/.bashrc; source ~/.bashrc
03 $ mkdir ~/wego
04 $ go get github.com/schachmat/wego
05 $ echo 'export PATH="$PATH:$GOPATH/bin"' >> ~/.bashrc; source ~/.bashrc

Next, you need to set up an environment for Go. To integrate a Go environment, you first need to set an environmental variable for Go. The command from the second line of Listing 1 writes the GOPATH to the .bashrc file, the shell configuration file.

Now check Wego out of GitHub – that is, download the code to your computer. To do this, create the directory specified in the environmental variable and pick up the code from GitHub (Listing 1, lines 3 and 4). You could start Wego now, by changing to the directory with the executable and typing ./wego. However, to make the call more convenient, and to be able to call Wego as a user from anywhere in the terminal, you need to set a second environmental variable that adds /bin to your GOPATH (Listing 1, line 5).

After you add /bin, you can launch Wego in a terminal simply by typing wego. However, you will still not see the weather displayed when you first start – the program needs you to point it to the data source. Instead, you just see two error messages (Listing 2). The first line is simply telling you that the program creates the hidden configuration file, ~/.wegorc, when first launched. You will need to edit this file now.

Listing 2

Error Messages

$ wego
No config file found. Creating /home/User/.wegorc ...
No API key specified. Setup instructions are in the README.

API Key

The second line refers to the API key, which you need to get to see the weather (Figure 2). To get the API key, surf to the website on https://developer.forecast.io/register. After you have registered, your free API key will be presented to you. Then, copy the APIKey to the hidden .wegorc file in your home directory (Listing 3).

Listing 3

Specify Location

{
  "APIKey": "MyAPIkey",
  "City": "Kansas City",
  "Numdays": 3,
  "Imperial": false,
  "Lang": "en"
}
Figure 2: The most important prerequisite for Wego is an API key.

You can specify a location (City) as well as the number of forecast days (Numdays) you want to see. If you want to specify values in imperial measures, change the setting for the Imperial keyword from false to true.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News