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