However, as predicted by previous ski bums, I have become more picky about what days I really want to go out and ski. If there isn't any fresh fluff, why bother waking up early? Hence, I've written an extension to my alarm clock script to check the snow report first. Only if there's more than a threshold level (currently 3") of the good stuff, will my alarm sound. Otherwise, it's sweet dreams and a natural wake up some point later in the day.
Snow Report
#!/bin/bash -l
#Script to check snowfall at Vail and Beaver Creek.
snowpath=http://www.snow.com/rssfeeds/
snowfile=snowreports.aspx
#Threshold level in inches
threshold=3
analyze ()
{
#Find the relevant lines in the snow report
vail=$(grep "Vail Resort Snow Report" $snowfile)
bc=$(grep "Beaver Creek Resort Snow Report" $snowfile)
if [ ${vail:39:2} -gt $threshold ] || [ ${bc:47:2} -gt $threshold
then
#We got threshold snow level
if [ ${vail:39:2} -gt ${bc:47:2} ]
then
echo "Vail got more gnarly powder than BC so go ski at Vail! ${vail:39:9}"
else
echo "BC got more gnarly powder than Vail so go ski at BC! ${bc:47:9}"
fi
#Sound the alarm!
bash /home/david/bin/alarm
else
echo "No new snow :-("
fi
}
if [ -e $snowfile ]
then
echo "Removing old file."
rm $snowfile
fi
echo "Retrieving snow report."
wget $snowpath$snowfile -q
if [ -e $snowfile ]
#File retreived
then
echo "Report retrieved. Running analysis."
analyze
else
echo "Damn, there was a web error."
#Run the alarm anyway. The internet's probably out due too much snow on transmission lines!
bash /home/david/bin/alarm
fi
Alarm
#!/bin/sh -l
# Alarm that slowly ramps up music volume
# Make new playlist
find ~/Music/ -iname "*.mp3" -print > /home/david/playlist.m3u
find ~/Music/ -iname "*.ogg" -print >> /home/david/playlist.m3u
#save original volume
initMasterString=$(amixer cget numid=1 | grep '[0-9][0-9],[0-9][0-9]')
initPCMString=$(amixer cget numid=6 | grep '[0-9][0-9],[0-9][0-9]')
initMaster=${initMasterString:`expr index "$(amixer cget numid=1 | grep '[0-9][0-9],[0-9][0-9]')" ,`}
initPCM=${initPCMString:`expr index "$(amixer cget numid=6 | grep '[0-9][0-9],[0-9][0-9]')" ,`}
amixer -c 0 set Master,0 unmute>&waste.txt
echo "Initial Master: $initMaster"
echo "Initial PCM: $initPCM"
#set volume to initial
for (( volume = $initMaster; volume <= 31; volume++ )) do amixer -q cset numid=1 $volume done amixer -q cset numid=1 100% amixer -q cset numid=6 0 #load music player mplayer -ao alsa -shuffle -quiet -playlist /home/david/playlist.m3u >&alarmout.txt &
#ramp up volume
for (( volume = 0; volume <= 255; volume++ ))
do
amixer -q cset numid=6 $volume
#uncomment to display shit
#echo $volume
sleep .5s
done
#wait for user to wake up at loud volume
sleep 70s
if test -z $(pidof mplayer); then
#mplayer not running, user cancelled alarm
echo "Alarm cancelled by user."
else
#mplayer running, stop playing
killall mplayer
echo "Alarm timed out. No user input."
fi
#return volume to original value
amixer -q cset numid=1 $initMaster
amixer -q cset numid=6 $initPCM



We stopped to talk to one woman whose job it was to load the cartridges that are then fed into the looms. For 12 hours per day, 7 days per week, and 51 weeks per year, she sits on a short stool on the concrete floor loading thread onto the cartridges. The pay is actually reasonable by Chinese standards, 80元/day and both room and board are provided. However, it's two thirds of what I make and I'm working 4 hours per day, 3 days per week, and 32 weeks per year. I couldn't help but feel sorry for her, although in her mind I'm sure 80元/day in the factory is a hell of a lot better than 10元/day on a farm in her home province.