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?
|
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
and the command What could be the reason? |
|||||||||
|
|
First run 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 # ugly and loud noise, getting on everyone's nerves; this should be done by a # nice pulseaudio bing (Ubuntu: #77010) # blacklist pcspkr |
|||||||||
|
|
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
Then have it available as a command
Now just run
|
|||||||||||||||||||||
|
|
To fix this problem persistently:
The simplest way to activate this solution is to reboot. Further, to implement this solution immediately for a terminal window that is already open, run the |
|||||||||||||||||||||
|
|
Since this is a very high rated question on google, I'll add the steps I did to re-enable beep in both console and X11: For the Linux Console (CTRL+ALT+F1...F6):Why it does not work by defaultAs already answered, the Temporarily enable until reboot:
Automatically enable on boot:
(delete or comment For X11 terminals (such as the default
|
|
|
To automatically enable a pc speaker beep on boot you have to actually comment said line in /etc/modprobe.d/blacklist.conf not uncomment it (you want to disable blacklisting, not the other way around).
– o'rety
Sep 16 '16 at 11:18
|
||
|
|
|||
|
|
both solutions work on Ubuntu 16.04 Note:
pcspkr and bell.ogg are independent approaches. beep tries to beep using various approaches e.g., ioctl(console_fd, KIOCSOUND, period) use pcspkr (the sound is coming from PC speaker on the motherboard) while printf '\a' -based method may work without it using only bell.ogg (the sound is from ordinary speakers). The second method might not work until pulseaudio service is started and/or xset b on is run
– jfs
Oct 13 '16 at 0:43
|
||
|
|
The
pactl upload-sample ... was golden for me. What's the way to permanently configure the sample loading again?
– ulidtko
Nov 29 '16 at 22:15
|
||
|
|
@ulidtko: Just add those lines lines in your
~/.profile, or system-wide at /etc/profile
– MestreLion
Feb 6 '17 at 15:40
|
|
I've encountered this problem before. From what I remember, the problem is that the terminal bell tries to ring an internal computer speaker (as in an old-school desktop) but laptops and some newer computers are missing such a thing. The only solution I found at the time was to
e.g.
|
|||||||||
|
|
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. |
|||
|
|
|
As far as I can tell, this is a bug: System beep broken in Karmic despite heroic efforts to fix it. |
|||||
|
|
I finally found a solution, which doesn't require uncomment the following in
per this bug, run |
|||||||||||||||||
|