Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to use a beep sound in a shell script. Unfortunately none of the methods I found via Google work for me.

I tried

echo -e '\a'

echo -ne '\007'

and the command beep after I installed it via apt.

What could be the reason?

share|improve this question

5 Answers 5

up vote 28 down vote accepted

First run sudo modprobe pcspkr and then beep should work.

The reason this doesn't is because by default Ubuntu no longer loads the hardware driver that produce beeps.

If this works for you then to enable the loading of pcspkr permanently edit the /etc/modprobe.d/blacklist.conf file (using gksudo gedit perhaps) and comment out line that says blacklist pcspkr so it looks like this:

# ugly and loud noise, getting on everyone's nerves; this should be done by a
# nice pulseaudio bing (Ubuntu: #77010)
# blacklist pcspkr
share|improve this answer
    
yes, tried that and it works. how can i force ubuntu to load pcspkr at boot? –  NES Jan 3 '11 at 20:52
    
@NES Have updated my answer –  8128 Jan 3 '11 at 21:06
    
thanks a lot, works fine. –  NES Jan 3 '11 at 21:11
1  
If I comment blacklist pcspkr I have to do modprobe -r pcspkr && modprobe pcspkr to get it to work. Also getting beep to work is not the same as getting the audible bell to work and thus askubuntu.com/questions/22168/how-do-i-enable-the-terminal-bell should still be open. –  daithib8 Jul 28 '11 at 11:37

Not being a fan of the pcspkr beep, I use a beep from one of the system sounds with the installed pulseaudio server's paplay command.

First find a sound you like (you can browse /usr/share/sounds for some available ones for example) and create a reference to it

export BEEP=/usr/share/sounds/KDE-Im-Message-In.ogg

Then have it available as a command

alias beep='paplay $BEEP'

Now just run beep whenever you need it. For example, to alert you when a command is finished:

find . | grep treasure ; beep
share|improve this answer
    
Very cool! It works! –  Hengjie Feb 19 '13 at 3:22
    
Thanks, this was useful for me! –  h3nr1x Jun 12 '13 at 3:57
    
This wasn't the answer I expected, but I like it better. –  isaaclw Jun 20 '13 at 16:55

As far as I can tell, this is a bug.

share|improve this answer

If you have actual speakers connected to the computer and you're not getting a beep it's likely because you are using compiz. Compiz is relying on pulseaudio catching the beeps and playing them while metacity bypasses the usual setup and uses libcanberra to play a beep sound. If it works with metacity and not compiz that is your problem, otherwise the answer htorque gave is corrent.

share|improve this answer

This answer is what worked for me.

I think it was specifically the bit to remove the pulseaudio-module-x11 package.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.