Permalink
Browse files

Add support for dynamic weather icon in Default mode

The Yahoo weather page that is currently used also contains a code to describe the current conditions.  This patch matches that code against a glyph stored in the ConkyWeather.ttf font.  The mapping between the font and the API code is obtained from here:
http://bazaar.launchpad.net/~conky-companions/+junk/conkyforecast/view/head:/conkyForecast.py#L225
  • Loading branch information...
1 parent d5a5022 commit 4febb7755f69c647430f7c3d054069f435d22eef @android-808 android-808 committed Sep 28, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 conkycolors/bin/conkyYahooWeather
  2. BIN fonts/conkycolors/ConkyWeather.ttf
@@ -5,6 +5,7 @@ MIN="min"
MAX="max"
CUR="cur"
UNIT="c"
+CODE="code"
if [ "$1" = "$CUR" ]; then
if [ "$3" = "$UNIT" ]; then
@@ -16,4 +17,15 @@ elif [ "$1" = "$MAX" ]; then
curl -s --connect-timeout 30 "http://weather.yahooapis.com/forecastrss?p=$2&u=$3" | sed '/Current\ Conditions/,$!d' | sed -e 's/<[^>]*>//g' | sed '4!d' | sed 's/^.*High: //' | sed 's/ Low.*$//'
elif [ "$1" = "$MIN" ]; then
curl -s --connect-timeout 30 "http://weather.yahooapis.com/forecastrss?p=$2&u=$3" | sed '/Current\ Conditions/,$!d' | sed -e 's/<[^>]*>//g' | sed '4!d' | sed 's/^.*Low: //'
+elif [ "$1" = "$CODE" ]; then
+YAHOOCODE=$(curl -s --connect-timeout 30 "http://weather.yahooapis.com/forecastrss?p=$2&u=$3" | sed '/<yweather:condition/,1!d' | sed 's/.*code="\([^"]*\)".*/\1/')
+WEATHERCHAR=(1 2 3 n m x x y s h t h i p p 8 q u w 7 0 9 4 6 6 - f D d C c A a B b v 5 k k g j o r r - G 0 K)
+if [ "$YAHOOCODE" == "na" ]; then
+ echo "-"
+elif [ "$YAHOOCODE" == "-" ]; then
+ echo "-"
+else
+ echo ${WEATHERCHAR[$YAHOOCODE]}
fi
+fi
+
Binary file not shown.

0 comments on commit 4febb77

Please sign in to comment.