Skip to content

Instantly share code, notes, and snippets.

@Quantum-cross
Created January 23, 2016 23:29
Show Gist options
  • Save Quantum-cross/433537d9d29b5abeed08 to your computer and use it in GitHub Desktop.
Save Quantum-cross/433537d9d29b5abeed08 to your computer and use it in GitHub Desktop.
#!/bin/bash
function handleConditions {
Y=8
W=false
SF=100
SNOWING=true
case "$1" in
"Light Snow" )
SF=100
;;
"Snow" )
SF=500
;;
"Heavy Snow" )
SF=1000
;;
"Light Snow Grains" )
SF=100
;;
"Snow Grains" )
SF=500
;;
"Heavy Snow Grains" )
SF=1000
;;
"Light Ice Crystals" )
SF=100
Y=100
;;
"Ice Crystals" )
SF=500
Y=100
;;
"Heavy Ice Crystals" )
SF=1000
Y=100
;;
"Light Ice Pellets" )
SF=100
Y=100
;;
"Ice Pellets" )
SF=500
Y=100
;;
"Heavy Ice Pellets" )
SF=1000
Y=100
;;
"Light Hail" )
SF=100
Y=100
;;
"Hail" )
SF=500
Y=100
;;
"Heavy Hail" )
SF=1000
Y=100
;;
"Light Low Drifting Snow" )
SF=100
W=true
;;
"Low Drifting Snow" )
SF=500
W=true
;;
"Heavy Low Drifting Snow" )
SF=1000
W=true
;;
"Light Blowing Snow" )
SF=100
W=true
;;
"Blowing Snow" )
SF=500
W=true
;;
"Heavy Blowing Snow" )
SF=1000
W=true
;;
"Light Snow Showers" )
SF=50
;;
"Snow Showers" )
SF=200
;;
"Heavy Snow Showers" )
SF=400
;;
"Light Snow Blowing Snow Mist" )
SF=50
W=true
;;
"Snow Blowing Snow Mist" )
SF=200
W=true
;;
"Heavy Snow Blowing Snow Mist" )
SF=400
W=true
;;
"Light Ice Pellet Showers" )
SF=50
Y=100
;;
"Ice Pellet Showers" )
SF=200
Y=100
;;
"Heavy Ice Pellet Showers" )
SF=400
Y=100
;;
"Light Hail Showers" )
SF=50
Y=100
;;
"Hail Showers" )
SF=200
Y=100
;;
"Heavy Hail Showers" )
SF=400
Y=100
;;
* )
SNOWING=false
esac
}
STATE=NY
CITY=New_York
API="http://api.wunderground.com/api/0d486af3b1a7e842/conditions/q/$STATE/$CITY.json"
PREVCONDS=""
while true
do
CONDS=$(curl -s "$API" | grep \"weather\" | cut -d \" -f 4)
if [ "$CONDS" != "$PREVCONDS" ]; then
handleConditions $CONDS
killall xsnow
if [ "$SNOWING" = true ]; then
WINDFLAG="-nowind"
if [ "$W" = true ]; then
WINDFLAG=""
fi
xsnow -nosanta -norudolf -windtimer 1 -snowflakes $SF -yspeed $Y $WINDFLAG &
fi
PREVCONDS="$CONDS"
fi
sleep 600
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment