Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Nice | 7 comments | Create New Account
Click here to return to the 'Nice' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Nice
Authored by: Anonymous on Jan 11, '02 05:51:27AM

This is nice. And it's really easy to modify to make a sleep-timer as well.

#!/bin/sh
# This script plays music and speaks to you to wake you up
# after a specified number of hours & minutes
# Functions
#--------------------------------
music_app="iTunes"
speak_message()
{
message="$*"
echo "say "$message"" | /usr/bin/osascript
}
speak_time()
{
hour=`date "+%H"`
time=`date "+%I %M"`
if [ $hour -le 11 ]; then
message="It is now $time A-M"
else
message="It is now $time P-M"
fi
speak_message $message
}
start_music()
{
artist="$*"
echo "tell application "$music_app" to play (some track of playlist "Library" whose artist is "$artist")" | /usr/bin/osascript
}
# Command-line arguments
#--------------------------------
if [ $# -lt 1 ]; then
echo "Usage: $0 hours [minutes]"
exit
fi
hours=$1
minutes=0
if [ $# -gt 1 ]; then
minutes=$2
fi
ack_msg="I will stop this in $hours hours and $minutes minutes"
speak_time
speak_message $ack_msg
artist1="Philip Glass"
start_music $artist1
delay_seconds=`expr $hours * 3600 + $minutes * 60`
sleep $delay_seconds
echo 'tell application "iTunes" to quit' | osascript
exit 0



[ Reply to This | # ]