Weather
Ansiweather is a small terminal program, that lets you check weather data via commands in the terminal.
Open Terminal and run the command:
sudo apt-get install ansiweather
Enter your password and hit Enter.
to install it.
Once you installed it you can run it with Terminal with the command:
ansiweather
to change the config file in Terminal run:
nano ~/.ansiweatherrc
there you can change the color of the output, location, greetings text etc.
See https://github.com/fcambus/ansiweather for more details.
For example:
background:\33[0m
text:\33[0m
data:\33[32m
delimiter:\33[0m
dashes:\33[0m
location:London,GB
fetch_cmd:curl -s
units:metric
symbols:true
show_daylight:true
timeformat:%b %d %R
forecast:0
greeting_text:Weather in
wind_text:\nWind speed
humidity_text:\nHumidity
pressure_text:\nAir pressure
sunrise_text:\nSunrise
sunset_text:\nSunset
# Icons
sun:\033[33;1m\xe2\x98\x80
moon:\033[36m\xe2\x98\xbd
clouds:\033[37;1m\xe2\x98\x81
rain:\xe2\x98\x94
fog:\033[37;1m\xe2\x96\x92
mist:\033[34m\xe2\x96\x91
haze:\033[33m\xe2\x96\x91
snow:\033[37;1m\xe2\x9d\x84
thunderstorm:\xe2\x9a\xa1
Crtl+X to exit, Y+Enter to accept changes.
Ansiweather cannot be run through the GeekTool Shell commands, therefore you have to work around a little bit.
You can set up a Cronjob to create a .txt file of the Ansiweather output which again can be displayed in Geektool.
For that you have to edit the systemwide Crontab:
sudo nano /etc/crontab
Enter your password and hit Enter.
Insert following text:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
* * * * * root ansiweather > /"Path were the Textfile should be saved".txt/
Change the asterisks to set up the refresh rate.
*\5 * * * *
-> refreshing every 5 minutes.
30 * * * *
-> resfreshing every half hour.
See https://crontab.guru/ for more options.
Crtl+X to exit, Y+Enter to accept changes.
Once you are happy with all your settings, create a new Shell window in Geektool and insert the command
cat /"Path were the Textfile has been saved".txt/
Location Update
If you want to tell Ansiweather your current location you can write a small Shell-Script that will update the Ansiweather config file. Open Terminal and type:
nano /"Path of your shell-scrip".sh
And insert following text:
#!bash
curl "http://api.ipinfodb.com/v3/ip-city/?key=77aefa17ff64cff681bc8f6dd12f513b77356c469edbf1c345583451d45b07b2&format=raw" > /"Path of your location textfile".txt
city="$(cat /"Path of your location textfile".txt | cut -d ";" -f7)"
country="$(cat /"Path of your location textfile".txt | cut -d ";" -f4)"
perl -i -pe 's/.*/location:'${city}','${country}'/ if $.==7' ~/ansiweatherrc
Crtl+X to exit, Y+Enter to accept changes.
This will get your location via the ipinfo.io API, save the output as a textfile and copy the city name and country code into the Ansiweather config file. Be sure that location= is in the 7th row in your ansiweatherrc config file., otherwise edit $.==7
into the correct row number.
To set the refresh rate of the location script you have to set up another Cronjob. This time it does not have to be systemwide. Use following command in Terminal:
export VISUAL=nano; crontab -e
and insert the text:
* * * * * sh /"Path of your shell script".sh
Change the asterisks to set up the refresh rate.
*\5 * * * *
-> refreshing every 5 minutes.
30 * * * *
-> resfreshing every half hour.
See https://crontab.guru/ for more options.
Crtl+X to exit, Y+Enter to accept changes.
Please set up the refresh rate to more than 5 minutes, because it uses my personal API key, which only allows 60 updates per minute