make beep

Carl Karsten <[email protected]> Fri, 3 Jun 2011 20:31:28 -0500
Newsgroups gmane.org.user-groups.luni.tech
Message-ID <[email protected]>
I want a light weight way to make a beep using standard tools - no
writing C, just install from standard repos, or best if it is part of
the ubuntu-desktop install.   It should respect the system's
mute/volume controls.

I am making my laptop beep and blop when I plug/unplug a card.  Turns
out that the unplug events happen at 2 and 12 seconds after the card
has actually left the slot.  And now I am paranoid that weird things
will happen if I plug something in before all the remove events have
fired.  So I want distinctive noises.  Super cool would be to start a
tone playing at the 1st remove event and turn it off at the 2nd.

I have come up with the following:

/usr/bin/sox -n -d synth .1 sin 700; /usr/bin/sox -n -d synth .1 sin 500

-n = no input file
-d = use default alsa device
synth .1 sin 700 = .1 second 700hz sin wave

Here is it being used in udev:

/etc/udev/rules.d/pci-beep.rules

SUBSYSTEM=="pci", ACTION=="add", RUN+="/usr/bin/sox -n -d synth .1 sin
500", RUN+="/usr/bin/sox -n -d synth .1 sin 700"

SUBSYSTEM=="pci", ACTION=="remove", RUN+="/usr/bin/sox -n -d synth .1
sin 700", RUN+="/usr/bin/sox -n -d synth .1 sin 500"

SUBSYSTEM=="firewire", ACTION=="remove", RUN+="/usr/bin/sox -n -d
synth .3 sin 700"

My biggest problem with this is the small gap between the 700 and
500s.  and sox can do all sorts of stuff, so having a kernel process
spawing it makes me grumpy.

and I just wanna know what my options are.


-- 
Carl K
-- 
Linux Users Of Northern Illinois (Chicago) - Technical Discussion 
http://luni.org/mailman/listinfo/luni