[wellylug] Non-console Beep for linux ?
Ewen McNeill
wellylug at ewen.mcneill.gen.nz
Wed Sep 21 10:17:35 NZST 2005
In message <Pine.LNX.4.61.0509171707350.6184 at localhost>, David Antliff writes:
>On Sat, 17 Sep 2005, Tony Wills wrote:
>> Does anyone know of a small linux program to beep the built in PC speaker
>> that doesn't need the console device? (ie not echo -e "\a")
>
>Yes it's called 'beep'. Seriously. It's good - you can choose frequency
>and duration and make little chimes with it:
>From beep.c (in the "beep" that is in Debian Sarge):
-=- cut here -=-
void play_beep(beep_parms_t parms) {
int i; /* loop counter */
/* try to snag the console */
if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) {
if((console_fd = open("/dev/vc/0", O_WRONLY)) == -1) {
-=- cut here -=-
which shows the very first step is to open tty0 (the console), or the
first virtual console. It then uses ioctl() on the console device, to
start and stop the sound, for which the implementation is in the virtual
console deriver.
As such I think it fails Tony's requirements for a "beep" program that
doesn't need the console device.
But yes, it's quite a cool program, and was my first thought
when I saw Tony's request.
Ewen
More information about the wellylug
mailing list