Subject: /dev/spkr is cool! (was: new console driver code)
To: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
From: Brian C. Grayson <bgrayson@ece.utexas.edu>
List: port-i386
Date: 03/25/1998 01:04:06
Matthias Drochner wrote:
> 
> The attribute "pckbd" in the kernel configuration files
> - where PS/2 mice (pms) and that speaker device which
> probably nobody uses (spkr) attach to - is now called
> "pckbcport".

  I'm probably in the minority, but I think /dev/spkr is quite
handy, so I'm speaking up in its defense!  I use it for
`asynchronous human notification.' I wrote a shell script,
`tune,' that uses a numeric argument to select one of 8
3-note blips to play through /dev/spkr.  One great thing about
/dev/spkr as compared to, for example, X-based beeps, is that
/dev/spkr works regardless of whether or not you are in X.

Examples of how I use it:

  1.  My ISP doesn't always get PPP right on the first try, so my
  chat script looks at the return code, and when ppp is
  _actually_ up, it plays `tune 1'.  I wait until I hear that,
  and then start slogins etc.

  2.  I usually use one tvtwm screen for my processor simulator source
  code, another for my virtual library source code, another
  for my simulated-application source code (SPLASH-2, etc.), and
  a final one to hold xterms for running simulations.
  Frequently, I need to recompile one thing, and then run a
  simulation in the different tvtwm screen.  I type `gmake;
  tune 2' in the compile xterm, then flip to the other tvtwm
  screen, type the simulation command, and wait for the tune before
  pressing Enter.  Saves me a few seconds and a few keypresses,
  and in a tight compile-run-debug cycle, it makes a difference.
  If I use (gmake && tune 1) || tune 2 (or something similar),
  then I can tell whether or not the compile succeeded
  according to the tune without looking.

  3.  I frequently run simulations on a bunch of machines via
  slogin xterms, and since I use tvtwm, I don't always notice
  (for minutes/hours!) when a program finishes execution.  I
  tell one remote machine running a simulation to do an ssh to
  my workstation and run `tune 1' when its current simulation
  finishes.  Another machine runs `tune 2'.  I get instant
  notification that (a) a simulation finished, and also (b)
  _which_ simulation finished, without resorting to things like
  mailing myself a message or constantly doing alt <- and alt
  -> to scan all the tvtwm screens.


  One idea is to come up with a short 1- to 5-note tune for
each different errno message, and modify perror() and err()
and warn() to optionally (locale-settable) play the tune. 
Sort of like MacOS's per-error customizable sounds!

  Another idea is getting a whole bunch of i386 boxes to use
/dev/spkr to cooperatively play a multiphonic song (since each
spkr can only play one note at a time).  Great way to freak out
coworkers...

  So there's a lot of "useful" things the spkr is good for.  :)
Anybody else doing anything interesting with it?

  Brian
--
Brian Grayson (bgrayson@ece.utexas.edu)
Graduate Student, Electrical and Computer Engineering
The University of Texas at Austin
Office:  ENS 406       (512) 471-8011
Finger bgrayson@orac.ece.utexas.edu for PGP key.