Updated 2013-08-14 00:11:13 by RLE

alarm is one of the many commands available in the Tclx package.
alarm seconds

Instructs the system to send a SIGALRM signal in the specified number of seconds. This is a floating point number, so fractions of a second may be specified. If seconds is 0.0, any previous alarm request is canceled. Only one alarm at a time may be active; the command returns the number of seconds left in the previous alarm. On systems without the setitimer system call, seconds is rounded up to an integer number of seconds.

The alarm command is not available on Windows 95/NT.

Note that when the SIGALRM is raised, the application will terminate if you have not previously set up your script to trap the signal.

Paul Walton Mach 28, 2006

Here'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 &]


proc MonitorTime {} {
        global Alarm
        global WakeUpTime
        if { $Alarm  &&  [clock seconds] >= [clock scan $WakeUpTime] } {

        after 1000 MonitorTime

vwait forever