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 >
Wrap
Text File
|
1995-05-20
|
8KB
|
194 lines
Visible bell mini-Howto
Alessandro Rubini, rubini@ipvvis.unipv.it
v2.00, May 1995
This doc explains something about termcap usage and provides a pointer
to a kernel patch to completely disable audible bells on demand.
1. Introduction
The Linux console driver beeps the audible bell whenever a BEL char is
output (ASCII code 7). Though this is a right choice for the default
behaviour, many users don't like their computer to beep. This mini-
Howto is meant to explain how to tell applications not to output the
BEL code. Pointers to a kernel patch are provided as well. The patch
is intended as a catch-all approach to avoid mangling with termcap and
applications' defaults.
In my opinion the best solution is a hardware one, and my own computer
doesn't even embed a loudspeaker.
2. Spekearectomy
Speakerectomy is by far the most brilliant solution to the audible
bell problem. It is the simplest way to remove beeps, though some
additional notes are worth.
PC's are usually equipped with a silly switch to toggle the mainboard
clock to a lower speed. The switch is completely unneeded when you
work in a multitasking environment, and even its original function to
slow down old dos games based on software-loop delays is no more used.
Unfortunately we can't use the switch to increase processor speed, but
we can turn it in a speaker enable/disable toggle. It is nice when
your computer beeps at you to signal the end of a lenghty compilation.
To modify the switch functionality, just detatch it from the main
board and connect its wires in series with the loudspeaker. That's all
to it.
Owners of laptop boxes, unfortunately, don't have easy access to the
lousspeaker, and neither have a spare switch to turn in an useful
toggle. The preferred solution for such users is trying to configure
their software to avoid beeping.
3. Basic Concepts about termcap
The file /etc/termcap is a text file which lists the terminal
capabilities. Several applications use the termcap information to move
the cursor in the screen and do other screen-oriented tasks. tcsh,
bash, vi and all the curses-based applications use the
termcapdatabase.
The database represents various terminal types, and applications use
the TERM environment variable to refer to the right entry in termcap.
Each capability is then represented by a two-letter code associated to
the character string used to get the desired effect. The separator
character between different capabilities is colon (":"). As an
example, the audible bell, whith code "bl", is usually represented by
the string "bl=^G", which instructs the applications to use the
control-G character, the ASCII BEL.
In addition to the bl capability, there is a vb capability, which
represents the "visible bell". vb is usually missing in the console
entry in Linux' /etc/termcap.
4. Defining a visible bell
You can add the entry for the vb capability in your own termcap file.
Dennis Henriksen (duke@diku.dk) suggested to insert the following line
in the termcap entry for console:
:vb=\E7\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E[?5h\E[?5l\E8:\
The trailing backslash is used to escape the newline in the database.
Dennis' code does the following (his own words):
o Save the cursor position (Just a safety precaution)
o Change the background color several times between normal and
reverse
o Restore the cursor position.
Some warnings about modifying termcap:
o Check what your TERM variable looks like: it used to be "console",
but it depends on your distribution and kernel version. Actually,
it is due to change to "linux".
o Check if the vb field is already there, distributors are reading
docs and upgrading their software all the time.
o Some applications don't use termcap but the terminfo database.
They won't sense your vb entry. Terminfo is more powerful than
termcap, as well as more difficult.
5. Telling applications about it
This is an incomplete list of applications that can be instrued to use
the vb entry for the current terminal type:
o tcsh (6.04 and later): "set visiblebell". The instruction can
appear in .cshrc or can be issued interactively. To reset the
audible bell just "unset visiblebell". To disable any notification
issue "set nobeep".
o bash (with readline, as well as other readline based applications):
put "set prefer-visible-bell" in ~/.inputrc.
o nvi and elvis: put "set flash" in ~/.exrc or tell ":set flash"
interactively (note the colon). To disable the visible bell use
noflash in place of flash.
o emacs: put "(setq visible-bell t)" in your ~/.emacs. It is
disabled by "(setq visible-bell nil)".
o less: use "-q" on command line to use the visual bell, use "-Q" to
disable any reporting. Default options can be put in your
environment variable "LESS".
o screen: issue the CtrlA-CtrlG command. It works on all the virtual
screens. Refer to the man page under "CUSTOMIZATION" for setting
the default.
o xterm: xterm can convert each bell to either a visible or audible
signal. It defualt to audible, but you can use the "-vb" command
line option and the "xterm*visualBell: true" resource. You can
toggle visible/audible signaling on the fly with the control-
mouse-1 menu.
o other X applications: you can tell the X server the volume of the
bell, with the "-f volume" commandline option. "volume" is between
0 and 100. Refer to X docs/experts about how to pass command line
options to the server.
6. Disabling the audible bell
If you want to force the visible bell on your console you can replace
the "bl" entry in termcap with the same string suggested for "vb"
above. This approach can unload you from the task of customizing each
application. I use this option on all the machines where I can run
Linux.
Note that applications with hardwired bells in theis source code won't
be affected by this change.
7. Easier configurability
If you want the ability to choose between audible and visible bell on
a console basis, you can use two different terminal types for the
linux console. You can name them, for example, console and console-
vb. The console entry would be the original one, while the other
could feature a visual bell string for the "bl" item. Thus you can
change the behaviour of your bell on a console basis:
o With tcsh: "setenv TERM console-vb" to get a screen flash, and
"setenv TERM console" to get the audible beep.
o With bash: "TERM=console-vb; export TERM" for the flash, and
"TERM=console; export TERM" for the beep.
Note that the termcap format allows to define a terminal-type in
terms of another, so you need to insert in the database only the
differences. Refer to the manpages for more information.
8. Other solutions
The bad news is that not all the applications are termcap-aware. Most
small programs feature 'backslash-a' characters in the C source code.
Those chars become a literal ASCII BEL in the executable binary. Real
application don't usually fall in this category, but be careful of C
newcomers who give your their own programs; novice computer-science
students are the worst of all.
The only way to shut the loudspeaker for these applications is
spekearectomy, or a modification of the console driver in the kernel.
An old patch to the kernel is available by ftp from
iride.unipv.it:/pub/linux/. It was taken against the 1.1.31 kernel
sources, but it applies to older kernels as well. The patch comes
with a small user program to set/unset visible and audible bells on a
per-console basis. I'm not currently mantaining the patch, but if you
are interested in it drop me a note. If there's enough interest we
could even make it in the mainstream kernel.