How do I ring a bell?

Polytropon freebsd at edvax.de
Mon Oct 7 12:36:52 UTC 2013


On Mon, 07 Oct 2013 12:37:35 +0100, Frank Leonhardt wrote:
> In the good'ol days I could make UNIX ring a bell (literally) by sending 
> \a to the console TTY (an ASR33 in my case).

Ah, the famous ^G control character... :-)



> Now there's an electronic 
> synthesised ting or beep from an terminal emulator IF it's got a sound 
> card and so on, and an IBM-PC had a beep routine in the BIOS.

The terminal beep routine will primarily address the system's
speaker (located at or connected to the mainboard). A side
effect on the sound card is possible (the Logitech SoundMan
did have that feature), but it's not really in relation.



> Is there any way to make a noise through the built in "bell" speaker 
> found on an IBM PC compatible server box? Writing 007 to the BIOS cout 
> routine might do it, but I've realised I haven't got a clue how to do that.

Making it audible is part of the local terminal emulator,
either the TTY (text mode) driver or via xterm (or the
preferred alternative terminal emulator in X).

A simple

	printf "\a"

from the shell prompt should be sufficient. Note that if
you're running this in X, you have to make sure the bell
is not disabled. For example, put

	xset b 100 1000 15

in your ~/.xinitrc (or ~/.xsession respectively).

A more sophisticated interface is provided as soon as your
kernel has

	device speaker

compiled in (or speaker.ko has been loaded). Now you can
play wonderful music through the speaker. :-)

See "man 4 speaker" for details.

See the following shell script as an example of what you
can do:

#!/bin/sh
read -p "CW ===> " TEXT
echo ${TEXT} | morse | awk '{
        if(length($0) == 0)
                printf("P4\n");
        else {
                gsub(" dit", "P32L32E", $0);
                gsub(" di",  "P32L32E", $0);
                gsub(" dah", "P32L8E",  $0);
                printf("%sP16\n", $0);
        }
}' | dd bs=256 of=/dev/speaker > /dev/null 2>&1

Feel free to add support for reading from stdin so you can
listen to your console messages piped into the script. :-)

Always make sure that the system actually _has_ got an
internal speaker! I assume that modern PC hardware could
have it removed along with floppy drive connector, parallel
port or power switch.



> P.S. "cdcontrol -f /dev/mycdrom eject" is the best I've come up with so 
> far for getting attention.

That's a really clever idea, never heared of that. It has
the advantage of being permanent because the drive will
stay open when the sound of its motor has finished. :-)


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list