- alarm seconds
Paul Walton Mach 28, 2006Here's a simple alarm clock for Windows. I wrote it at 3 am when I really needed an alarm, so it was meant to just work and not be full of fancy features.Requires Windows Media Player, or any other media player you can start from the command line. Perhaps someone can add an interface, use Snack instead of an external player, and add some other neat features.Edit the globals WakeUpTime, MediaPlayer, and MediaFiles. Run with tclsh. Be sure to turn your speakers up.
set WakeUpTime "07:15"
set MediaPlayer [list {c:/program files/Windows Media Player/wmplayer}]
lappend MediaFiles {C:/Documents and Settings/Paul/My Documents/The Eagles - On the Border/04 - My Man.mp3}
lappend MediaFiles {C:/Documents and Settings/Paul/My Documents/The Eagles - On the Border/10 - The Best of My Love.mp3}
lappend MediaFiles {C:/Documents and Settings/Paul/My Documents/Hotel California/01 Eagles - Hotel California.mp3}
# If the WakeUpTime is already passed, turn alarm initially off. If the WakeUpTime has yet to pass, turn the alarm on.
if { [clock seconds] <= [clock scan $WakeUpTime] } {
set Alarm on
puts "Alarm is ON: $WakeUpTime"
} else {
set Alarm off
puts "Alarm is OFF"
}
proc SoundAlarm {} {
global Alarm
global MediaPlayer
global MediaFiles
if { $Alarm } {
puts "Sounding alarm!"
set Alarm off
eval [concat exec $MediaPlayer $MediaFiles &]
}
return
}
proc MonitorTime {} {
global Alarm
global WakeUpTime
if { $Alarm && [clock seconds] >= [clock scan $WakeUpTime] } {
SoundAlarm
}
after 1000 MonitorTime
}
MonitorTime
vwait forever
