Now, why should I suffer alone? :D..
Now, dont blame me if this wakes you up... or hate me for writing this silly lil script.. (needs festival, totem, plugins for totem, internet connection and a really sleepy mind..#!/bin/bash
#Choose your favourite stations from shoutcast.com (net radio)
LINK="http://yp.shoutcast.com/sbin/tunein-station.pls?id=6063"
if [ $# -eq 0 ]; then
echo "usage $0 wakeup_duration"
echo "wakeup_duration: wakeup after how long? 6 hours, 1 hour, 20 mins etc. or even 5am tomorrow.."
exit 1
fi
NOW_SEC=$(date +%s)
WAKEUP_SEC=$(date +%s --date="$*")
if [ $? -ne 0 ]; then
echo "oopss.. i dont think date understands $*"
exit 2
fi
if [ $NOW_SEC -gt $WAKEUP_SEC ]; then
SLEEP_SEC=$(( $NOW_SEC - $WAKEUP_SEC))
echo "Do you wish to wakeup $SLEEP_SEC seconds previously??.."
echo "Sorry cant help you with that.. :("
exit 3
fi
SLEEP_SEC=$(( $WAKEUP_SEC - $NOW_SEC))
echo "NOW=$NOW_SEC WAKE=$WAKEUP_SEC DIFF=$SLEEP_SEC"
echo wakeup at `date --date="$*"`
#Trap CTRL+C and cleanup - set mute back..
trap cleanup 1 2 3 4 5 6
cleanup()
{
echo "Caught Signal from user- muting myself"
amixer -c 0 -- sset Master playback 0%
amixer -c 0 -- sset Master mute
amixer -c 0 set PCM 0%
exit 1
}
# unmute all
amixer -c 0 -- sset Master unmute
# Set my music volume
amixer -c 0 -- sset Master playback 30%
amixer -c 0 set PCM 100%
totem "$LINK" &
sleep $SLEEP_SEC
killall totem
# Set my announce volume
amixer -c 0 -- sset Master playback 100%
amixer -c 0 set PCM 100%
i=0
# have I Really GONE BONKERS?
while [ $i -ne 5000 ]
do
echo "Attempt $i - CTRL+C to stop me screaming"
# You may want your favorite statement here..
echo '(SayText "Nishanth, wakeup dude.. time to go to office..")'|festival
i=`expr $i + 1`
done
No comments:
Post a Comment