Saturday, November 8, 2014

Beep in shell script

SRC: http://askubuntu.com/questions/19906/beep-in-shell-script-not-working

Solution 1)
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
 
Solution 2) 
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

No comments:

Post a Comment