bashwx is a python3 script that will put the current weather conditions, public IP and local IP in your .bashrc file to be displayed when you login
For the script to run correctly you will need to obtain an API key from https://home.openweathermap.org/users/sign_up and add it to "app_id = " value. The service is free. Following that, place bashwx in /usr/sbin/ and setup a chrontab to run it hourly or half-hourly or whenever you want. I intitally wanted the script to run evry time that .bashrc was called but that will produce an error.
When you login to your shell the script will output the following:
[Local weather]: 81.68 F, with clear sky
[Your public IP is]: x.x.x.x [Local IP]: 192.168.x.x
-=skywalker@deathstar=-:[~/scripts/python/working]#
Additionally you can add the following lines to the bottm of your .bashrc to offer more info:
echo -e "Welcome to \e[0;37m[$(hostname)]\e[0m You are logged in as user \e[0;37m[$USER]\e[0m"
echo -e "[Local time]: \e[0;37m$(date)\e[0m."
All highlighting is white text so you may want to change that depending of your Term profile.
Hope you enjoy it!
bashwxplus
bashwxplus offers more data than bashwx. It will display your MOTD in a rainbow color format and much more weather data as well as astronomy. Instead of using openweathermap.org's api I opted for weatherunderground which offers more weather related data for the same amount of api calls. It is also free unless you plan on running over your call limit. You can sign up for an API key here: https://www.wunderground.com/weather/api/
to use bashwxplus you will have to run the script as with bashwx but in your .bashrc file you want to add the following lines to the bottom of the file.
cat ~/bashwx/motdplus
echo
if [ -s ~/bashwx/.alerts ]; then
echo ' To view active weather alerts type ''cat ~/bashwx/.alerts'
fi
setup a cron job to run every fifteen minutes:
$> crontab -e
0/15 * * * * ~/bashwx/bashwxplus0.1.py
the output will appear as follows:
MOTD HERE
Welcome [skywalker]
Your Public IP is [x.x.x.x] Your Local IP is [192.168.2.5]
Weather at [City, ST] from station [STATIONID]
Today's Forecast: [Sunny. High near 85F. Winds S at 10 to 15 mph.]
Conditions: [Partly Cloudy]
Winds: [Calm]
Temp: [62.1 F] feels like: [62.1 F]
Heat Index: [NA F] Wind Chill: [NA F] Dew Point: [58 F]
Humidity: [86%]
Barometric Pressure: [1016 mB (+)]
Rain Gauge: [0.00 in hourly] [0.00 in daily]
Moon Phase: [Waxing Crescent] illuminated [44%]
Sunrise: [6:32] Sunset: [20:02]
UV Levels: [1.0 mW/cm2] Radiation Level [148 W/m2] Visibility: [10.0 Miles]
Active alert: [Flood Warning]
[Last Updated on May 2, 8:14 AM CDT]
Verse of the Day: ["You also are among them, called to belong to Jesus Christ." - Romans 1:6]
To view active weather alerts type "cat /home/user/bashwx/.alerts"
skywalker@endor:~$