Wednesday, February 11, 2009

stupid little alarm program (bash script)

almost missing office hour due to jetlag is not a nice idea.. hence wrote this nonsense little script, which would stream a shoutcast stream while waiting to kick me up screaming..
Now, why should I suffer alone? :D..
#Choose your favourite stations from (net radio)
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
NOW_SEC=$(date +%s)
WAKEUP_SEC=$(date +%s --date="$*")
if [ $? -ne 0 ]; then
echo "oopss.. i dont think date understands $*"
exit 2
if [ $NOW_SEC -gt $WAKEUP_SEC ]; then
echo "Do you wish to wakeup $SLEEP_SEC seconds previously??.."
echo "Sorry cant help you with that.. :("
exit 3
echo wakeup at `date --date="$*"`

#Trap CTRL+C and cleanup - set mute back..
trap cleanup 1 2 3 4 5 6
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%
# have I Really GONE BONKERS?
while [ $i -ne 5000 ]
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`

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..

No comments: