home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / mini / visual-b < prev    next >
Encoding:
Text File  |  1996-07-11  |  8.2 KB  |  205 lines

  1.   Visible bell mini-Howto
  2.   Alessandro Rubini, rubini@ipvvis.unipv.it
  3.   v2.00, May 1995
  4.  
  5.   This doc explains something about termcap usage and provides a pointer
  6.   to a kernel patch to completely disable audible bells on demand.
  7.   ______________________________________________________________________
  8.  
  9.   Table of Contents:
  10.  
  11.   1.      Introduction
  12.  
  13.   2.      Spekearectomy
  14.  
  15.   3.      Basic Concepts about termcap
  16.  
  17.   4.      Defining a visible bell
  18.  
  19.   5.      Telling applications about it
  20.  
  21.   6.      Disabling the audible bell
  22.  
  23.   7.      Easier configurability
  24.  
  25.   8.      Other solutions
  26.   ______________________________________________________________________
  27.  
  28.   1.  Introduction
  29.  
  30.   The Linux console driver beeps the audible bell whenever a BEL char is
  31.   output (ASCII code 7).  Though this is a right choice for the default
  32.   behaviour, many users don't like their computer to beep. This mini-
  33.   Howto is meant to explain how to tell applications not to output the
  34.   BEL code. Pointers to a kernel patch are provided as well. The patch
  35.   is intended as a catch-all approach to avoid mangling with termcap and
  36.   applications' defaults.
  37.  
  38.   In my opinion the best solution is a hardware one, and my own computer
  39.   doesn't even embed a loudspeaker.
  40.  
  41.   2.  Spekearectomy
  42.  
  43.   Speakerectomy is by far the most brilliant solution to the audible
  44.   bell problem. It is the simplest way to remove beeps, though some
  45.   additional notes are worth.
  46.  
  47.   PC's are usually equipped with a silly switch to toggle the mainboard
  48.   clock to a lower speed. The switch is completely unneeded when you
  49.   work in a multitasking environment, and even its original function to
  50.   slow down old dos games based on software-loop delays is no more used.
  51.   Unfortunately we can't use the switch to increase processor speed, but
  52.   we can turn it in a speaker enable/disable toggle. It is nice when
  53.   your computer beeps at you to signal the end of a lenghty compilation.
  54.  
  55.   To modify the switch functionality, just detatch it from the main
  56.   board and connect its wires in series with the loudspeaker. That's all
  57.   to it.
  58.  
  59.   Owners of laptop boxes, unfortunately, don't have easy access to the
  60.   lousspeaker, and neither have a spare switch to turn in an useful
  61.   toggle.  The preferred solution for such users is trying to configure
  62.   their software to avoid beeping.
  63.  
  64.   3.  Basic Concepts about termcap
  65.  
  66.   The file /etc/termcap is a text file which lists the terminal
  67.   capabilities. Several applications use the termcap information to move
  68.   the cursor in the screen and do other screen-oriented tasks.  tcsh,
  69.   bash, vi and all the curses-based applications use the
  70.   termcapdatabase.
  71.  
  72.   The database represents various terminal types, and applications use
  73.   the TERM environment variable to refer to the right entry in termcap.
  74.   Each capability is then represented by a two-letter code associated to
  75.   the character string used to get the desired effect.  The separator
  76.   character between different capabilities is colon (":").  As an
  77.   example, the audible bell, whith code "bl", is usually represented by
  78.   the string "bl=^G", which instructs the applications to use the
  79.   control-G character, the ASCII BEL.
  80.  
  81.   In addition to the bl capability, there is a vb capability, which
  82.   represents the "visible bell". vb is usually missing in the console
  83.   entry in Linux' /etc/termcap.
  84.  
  85.   4.  Defining a visible bell
  86.  
  87.   You can add the entry for the vb capability in your own termcap file.
  88.   Dennis Henriksen (duke@diku.dk) suggested to insert the following line
  89.   in the termcap entry for console:
  90.  
  91.        :vb=\E7\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E8:\
  92.  
  93.   The trailing backslash is used to escape the newline in the database.
  94.   Dennis' code does the following (his own words):
  95.  
  96.   o  Save the cursor position (Just a safety precaution)
  97.  
  98.   o  Change the background color several times between normal and
  99.      reverse
  100.  
  101.   o  Restore the cursor position.
  102.  
  103.   Some warnings about modifying termcap:
  104.  
  105.   o  Check what your TERM variable looks like: it used to be "console",
  106.      but it depends on your distribution and kernel version.  Actually,
  107.      it is due to change to "linux".
  108.  
  109.   o  Check if the vb field is already there, distributors are reading
  110.      docs and upgrading their software all the time.
  111.  
  112.   o  Some applications don't use termcap but the terminfo database.
  113.      They won't sense your vb entry. Terminfo is more powerful than
  114.      termcap, as well as more difficult.
  115.  
  116.   5.  Telling applications about it
  117.  
  118.   This is an incomplete list of applications that can be instrued to use
  119.   the vb entry for the current terminal type:
  120.  
  121.   o  tcsh (6.04 and later): "set visiblebell".  The instruction can
  122.      appear in .cshrc or can be issued interactively. To reset the
  123.      audible bell just "unset visiblebell". To disable any notification
  124.      issue "set nobeep".
  125.  
  126.   o  bash (with readline, as well as other readline based applications):
  127.      put "set prefer-visible-bell" in ~/.inputrc.
  128.  
  129.   o  nvi and elvis: put "set flash" in ~/.exrc or tell ":set flash"
  130.      interactively (note the colon).  To disable the visible bell use
  131.      noflash in place of flash.
  132.  
  133.   o  emacs: put "(setq visible-bell t)" in your ~/.emacs.  It is
  134.      disabled by "(setq visible-bell nil)".
  135.  
  136.   o  less: use "-q" on command line to use the visual bell, use "-Q" to
  137.      disable any reporting. Default options can be put in your
  138.      environment variable "LESS".
  139.  
  140.   o  screen: issue the CtrlA-CtrlG command. It works on all the virtual
  141.      screens. Refer to the man page under "CUSTOMIZATION" for setting
  142.      the default.
  143.  
  144.   o  xterm: xterm can convert each bell to either a visible or audible
  145.      signal. It defualt to audible, but you can use the "-vb" command
  146.      line option and the "xterm*visualBell: true" resource. You can
  147.      toggle visible/audible signaling on the fly with the control-
  148.      mouse-1 menu.
  149.  
  150.   o  other X applications: you can tell the X server the volume of the
  151.      bell, with the "-f volume" commandline option. "volume" is between
  152.      0 and 100. Refer to X docs/experts about how to pass command line
  153.      options to the server.
  154.  
  155.   6.  Disabling the audible bell
  156.  
  157.   If you want to force the visible bell on your console you can replace
  158.   the "bl" entry in termcap with the same string suggested for "vb"
  159.   above.  This approach can unload you from the task of customizing each
  160.   application.  I use this option on all the machines where I can run
  161.   Linux.
  162.  
  163.   Note that applications with hardwired bells in theis source code won't
  164.   be affected by this change.
  165.  
  166.   7.  Easier configurability
  167.  
  168.   If you want the ability to choose between audible and visible bell on
  169.   a console basis, you can use two different terminal types for the
  170.   linux console.  You can name them, for example, console and console-
  171.   vb.  The console entry would be the original one, while the other
  172.   could feature a visual bell string for the "bl" item.  Thus you can
  173.   change the behaviour of your bell on a console basis:
  174.  
  175.   o  With tcsh: "setenv TERM console-vb" to get a screen flash, and
  176.      "setenv TERM console" to get the audible beep.
  177.  
  178.   o  With bash: "TERM=console-vb; export TERM" for the flash, and
  179.      "TERM=console; export TERM" for the beep.
  180.  
  181.      Note that the termcap format allows to define a terminal-type in
  182.      terms of another, so you need to insert in the database only the
  183.      differences.  Refer to the manpages for more information.
  184.  
  185.   8.  Other solutions
  186.  
  187.   The bad news is that not all the applications are termcap-aware. Most
  188.   small programs feature 'backslash-a' characters in the C source code.
  189.   Those chars become a literal ASCII BEL in the executable binary.  Real
  190.   application don't usually fall in this category, but be careful of C
  191.   newcomers who give your their own programs; novice computer-science
  192.   students are the worst of all.
  193.  
  194.   The only way to shut the loudspeaker for these applications is
  195.   spekearectomy, or a modification of the console driver in the kernel.
  196.  
  197.   An old patch to the kernel is available by ftp from
  198.   iride.unipv.it:/pub/linux/. It was taken against the 1.1.31 kernel
  199.   sources, but it applies to older kernels as well.  The patch comes
  200.   with a small user program to set/unset visible and audible bells on a
  201.   per-console basis. I'm not currently mantaining the patch, but if you
  202.   are interested in it drop me a note. If there's enough interest we
  203.   could even make it in the mainstream kernel.
  204.  
  205.