Visible bell mini-Howto: Per-console Beep Configuration

Rate this post

prev-9617204 next-5261504 toc-1067143

As of Linux 1.3.43, Martin Mares added configurability to the bell sound in console.c. You can change the duration and pitch of the console beep on a per-console basis, by writing escape sequences to the tty. You can apply your configuration in your own ~/.profile or ~/.login, to have a different beep (or no beep) associated to each console.

The escape sequences work as follow:

  • ESC-[10;xx] chooses the bell frequency in Hertz. The value should be in the range 21-32766, otherwise the result is undefined (at least up to the 2.0.x version — I can’t foresee the future. If the `xx’ argument is missing, the default value (750Hz) will apply, as in `ESC-[10].
  • ESC-[11;xx] chooses the bell duration, in milli-seconds. If you specify more than 2 seconds, the default applies (125ms). Once again, if the `xx’ argument is missing (ESC-[11]) the default value will be used.

To print the escape sequences, you can try for example (50Hz, 1s) « echo -e "\33[10;50]\33[11;1000]" » with bash (where « -e » means `understand escape sequences’. With tcsh « echo "\033[10;50]\033[11;1000]" will have the same effect.

Note that a new `setterm’ command might support bell configuration of command line, as these control codes are marked as `setterm-commands’. However, no `setterm’ version I know of supports these codes.

If you run Linux-1.3.43 or newer, you may be satisfied with the escape sequences and avoid reading further. If you run an older kernel (I do it myself, on a small 386), or if you want the visual bell, have a good reading.

Lire aussi...  Linux Site O' The Month: LG #49

prev-9617204 next-5261504 toc-1067143