Version 4 of Telephone Ring

Updated 2002-12-21 13:41:41

This is a little thing I wrote that simulates a telephone ring via the Linux console. The underlying console is used so that it can be used for Tcl and/or Tk.

I'd rather that this work via an open'ed FD on /dev/console but I can't seem to get that to work. It will ring ok, but doesn't change the frequency as it does via echo. But it does open a door to a lot of simple sound possibilities via the PC speaker, and without any extensions. Alarm clocks, fancy alerts, whatever...

This is not perfected yet. If run under a user's desktop it needs to be run by root (su root),

 # ring proc by Mike Tuxford
 proc ring {} {
   #                       duration (ms)
   exec /bin/echo -e '\\33\[11\;40]' > /dev/console
   for {set i 0} {$i < 8} {incr i} {
     #                       freq. (HZ)
     exec /bin/echo -e '\\33\[10\;770]' > /dev/console
     exec /bin/echo -e '\\a' > /dev/console
     after 40
     exec /bin/echo -e '\\33\[10\;870]' > /dev/console
     exec /bin/echo -e '\\a' > /dev/console
     if {$i == 3} {
       after 200
     } else {
       after 40
     }
   }
   # From the kernel console.c
   # Here is the default bell parameters: 750HZ, 1/8th of a second
   # reset the defaults
   exec /bin/echo -e '\\33\[10\;750\]\\33\[11\;125\]' > /dev/console
   return
 }
 ring

rmax - As it is, this program does funny things on the console. Mind you, that single quotes don't have a special meaning in Tcl. To quote the escape sequences, the single quotes should become pairs of braces, the single backslashes can go, and the double backslashes become single ones. Also echo should get a -n switch to avoid printing lots of newlines to the console. So the echos will look like this:

 exec /bin/echo -en {\33[11;40]} > /dev/console