Linux Tutorial: how to view weather forecasts under Linux Command lines
Q: I often view weather forecasts on Linux desktops. However, is there a way to query weather forecasts without using a desktop plug-in or a browser in a terminal environment?
For Linux Desktop Users, there are many ways to obtain weather forecasts, such as using specialized weather applications, desktop plug-ins, or panel applets. However, if your work environment is terminal-based, there are also some methods to obtain the weather in the command line.
One of them is wego, a small program under a terminal. Using the ncurses-based interface, this command line program allows you to view the current weather conditions and subsequent forecasts. It also collects weather forecasts for the next five days using an API for weather forecasting.
Install wego in Linux
Installing wego is quite simple. Wego is written in Go. The first step is to install Go. Then install wego.
$ go get github.com/schachmat/wego
Wego will be installed to $ GOPATH/bin, so add $ GOPATH/bin to the $ PATH environment variable.
$ echo'export PATH="$PATH:$GOPATH/bin"'>>~/.bashrc
$ source ~/.bashrc
Now we can start wego directly from the command line.
$ wego
When weg is run for the first time, a configuration file (~/.wegorc
), You need to specify a weather API key. You can get a free API key from worldweatheronline.com. Free registration and use. You only need to provide a valid email address.
Your. wegorc configuration file looks like this:
In addition to the API key, you can configure the location where you want to query the weather, the name of the city/country in use, and the language in~/.wegorc
. Note that this weather API has a limit: up to 5 queries per second, up to 250 queries per day. When you re-execute the wego command, you will see the latest weather forecast (of course your specific place), as shown in the question map.
The displayed weather information includes: (1) temperature, (2) wind speed and wind direction, (3) visible distance, (4) by default, the weather forecast for three days is displayed. If you want to modify the weather range, you can use the parameter to change the weather range (up to 5 days), for example, to view the weather forecast for 5 days:
$ wego 5
To check the weather in another place, you only need to provide the city name:
$ wego Seattle
Problem Solving
The following error may occur:
user:Currentnot implemented on linux/amd64
This error occurs when you run wego in an environment that does not support the native Go compiler. In this case, you only need to use gccgo -- A Go compiler frontend to compile the program. You can use the following command to complete this step.
$ sudoyum install gcc-go
$ go get-compiler=gccgo github.com/schachmat/wego
Via: http://ask.xmodulo.com/weather-forecasts-command-line-linux.html
Author: Dan Nanni Translator: oska874 Proofreader: wxy
This article was originally compiled by LCTT and launched with the honor of Linux in China
This article permanently updates the link address: