Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

Showing The Weather In Tmux

$
0
0

Written on September 23, 2016

The weather is unpredictable here on the North coast of Poland where I live, especially around this time of year. On those infrequent occasions when I do leave my apartment (I work from home), I’m never sure how warmly I should dress or how careful I should be on the road ― cold-snaps are increasingly frequent.

I spend most of my day staring at my terminal, so that’s where I’d like to keep all of the information I care about. My Tmux status bar currently contains my laptop’s remaining battery life, the current time and date, and now the local weather. Here’s how that looks:


Showing The Weather In Tmux
We’re Not In Kansas Anymore

The first thing we need to do is find our approximate geographical coordinates. I say approximate because I’m not willing to pay money for a high level of accuracy. Kinda-sorta where I live is good enough. Curiously enough, Google’s geolocation API seemed to be broken for me and ― after some research ― many other people.

I found a free service called IP-API. As the name suggests, it returns your location based on your IP address. The service allows up to 150 requests per minute which is plenty for our needs ― we won’t be making requests more than once per second.

Running the following command gives us a collection of values about our geographical data, separated by commas:

curl --silent http://ip-api.com/csv success,Poland,PL,PM,"Pomeranian Voivodeship",Gda

Viewing all articles
Browse latest Browse all 11063

Trending Articles