Created
March 3, 2014 00:35
-
-
Save raidzero/9316383 to your computer and use it in GitHub Desktop.
Get weather data from yahoo weather (meant for conky)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# USAGE: weather.sh [NULL|both|forecast] | |
LOCATION_URL="http://weather.yahooapis.com/forecastrss?p=USCO0105&u=" #Denver | |
WEATHER=`curl -s "$LOCATION_URL" | grep "F<BR" | awk -F ' F<BR' '{print$1}'` | |
TOMORROW=`date --date="tomorrow" +%a` | |
FORECAST=`curl -s "$LOCATION_URL" | grep -oE "^[A-Z][a-z]{2} - .*-?[0-9]{1,3}" | grep "^$TOMORROW" | sed -r 's_High: \<(-?[0-9]{1,3})\> Low: \<(-?[0-9]{1,3})\>_\2\/\1_'` | |
FORECAST=`echo $FORECAST | sed -r ' \ | |
s/\<Thunderstorms\>/T-storms/g; | |
s/\<Isolated\>/Iso/g; | |
'` | |
if [ "$1" == "both" ]; then | |
[ -n "$WEATHER" ] && echo "$WEATHER°F" | |
[ -n "$FORECAST" ] && echo "$FORECAST°F" | |
elif [ "$1" == "forecast" ]; then | |
[ -n "$FORECAST" ] && echo "$FORECAST°F" | |
elif [ -z "$1" ]; then | |
if [ -z "$WEATHER" ]; then | |
echo "No Internet connection." | |
else | |
echo "$WEATHER°F" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment