How to make the hardware beep sound in Mac OS X 10.6

BashMacosApplescriptBeep

Bash Problem Overview


I just want that Mac OS X 10.6 does a hardware beep sound like in open suse and other distributions. I tried following approaches

Terminal -> beep = -bash: beep: command not found

Terminal -> say beep = voice speaks out beep (Not a Hardware beep but awesome ;) )

applescript -> beep = Macintosh bell (I want a Hardware beep!)

Does anybody know how to make the Hardware beep in bin/bash or applescript?

Bash Solutions


Solution 1 - Bash

tput bel works in most shells.

In OS X, this (and any other command that makes the bell go off) also gets you a badge if the command is executed when Terminal was not in the foreground:

Solution 2 - Bash

Printing \a did not always work for me (MBA, 10.7.4). I use this instead:

say "beep"

Solution 3 - Bash

Indeed, the following is effective and somewhat melodic:

say -v Bells "dong dong dong"

[Update] Unfortunately Bells is no longer included in latest OS X. Try:

say -v Victoria Do your homework!

Use the following to explore voices:

say -v \?

Solution 4 - Bash

write echo ^G in the bash. to create the ^G press ctrl+v and then ctrl+g.

Solution 5 - Bash

This will loop through all the voices (works on Yosemite):

say -v '?' | awk '{print $1}' | while read voice; do printf "using $voice...\n"; say -v $voice "hello, this is me using the $voice voice"; sleep 1; done

Solution 6 - Bash

Play an arbitrary alert sound with afplay

I'm surprised nobody has mentioned afplay: that's the command line program that plays arbitrary sound files. It's been around since the original releases of OS X (and NeXTSTEP, if your memory is that long).

For example, you can run this from the command line or put it in a script:

$ afplay /System/Library/Sounds/Ping.aiff

You're not limited to system sounds; one advantage of using afplay is that you can choose your own sound file as an alert. For example, you could download one of these sound files and pick your favorite.

(Extra points if you can find a recording of an Teletype Model 33 bell!)

Solution 7 - Bash

There is no "hardware beep" in macOS.

The functionality you're thinking of is an artifact of very old (pre-1990s) IBM PC-compatible hardware. Before most computers had sound cards, most machines had a small speaker or piezo buzzer connected to one of the channels of a timer chip. This could be used to generate simple tones or beeps. Even after many computers integrated sound cards, it remained common for quite some time for computers to route this output to a separate internal speaker. More recently, many computers, especially laptops, have integrated this functionality into the onboard sound card.

(If you're curious about the technical details of how the PC speaker interface worked, there are more details here.)

This hardware has never existed in Apple computers. The only audio output available is through the sound card, and the only system beep in macOS is the user's alert sound.

Solution 8 - Bash

In the terminal type :

echo -e "\a"
The -e parameter tells echo to process escaped characters. As the \n is the new line character, the \a is the bell one (the same as Ctrl+G).

Solution 9 - Bash

Under OS X terminals, execute command: osascript -e 'beep'

Using OSA (Open Script Architecture) technology to tell AppleScript to execute command beep.

Solution 10 - Bash

printf "\a"

If you look at man printf, it gives you a list of escaped characters, including \a:

\a      Write a <bell> character.

Solution 11 - Bash

If you need something, that sounds like "important"

you can use

tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s && tput bel && sleep 0.33s

:)

Solution 12 - Bash

printf "\a" also works in a terminal and will play the set alert sound.

Solution 13 - Bash

This works for me (mac os 10.14.6)

echo "\x07"  

Solution 14 - Bash

on MacOS X, the "sound warning" option (Terminal/Preferences) has to be activated to get a sound.

Solution 15 - Bash

If you've got XCODE installed you can make a beep/bell. I haven't figured that I can make the printf "\a" character work in C.

There's one way to make the tone work as the program runs, start XCODE, drop down menu under XCODE, Preferences, Behaviours,check the first box PLAY SOUND, choose from the list or add a sound.

That's one way to do it, but only as the program runs, I believe.

Solution 16 - Bash

osascript -e 'tell application "System Events" to beep'

Solution 17 - Bash

For more options, hear and pick

ls /System/Library/Sounds/ | awk '{print $1}' | while read sound; do printf "using $sound...\n"; afplay /System/Library/Sounds/$voice; sleep 0.5; done

ls /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/ | awk '{print $1}' | while read sound; do printf "using $voice...\n"; afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/$sound; sleep 0.5; done

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionelhombreView Question on Stackoverflow
Solution 1 - BashbroofaView Answer on Stackoverflow
Solution 2 - BashAndreiView Answer on Stackoverflow
Solution 3 - Bashk00kaView Answer on Stackoverflow
Solution 4 - BashcoffeejunkView Answer on Stackoverflow
Solution 5 - BashJason Ryan TaylorView Answer on Stackoverflow
Solution 6 - Bashfearless_foolView Answer on Stackoverflow
Solution 7 - Bashuser149341View Answer on Stackoverflow
Solution 8 - BashZaphodView Answer on Stackoverflow
Solution 9 - BashAlbertView Answer on Stackoverflow
Solution 10 - BashAlex CoplanView Answer on Stackoverflow
Solution 11 - BashNedudiView Answer on Stackoverflow
Solution 12 - BashOantbyView Answer on Stackoverflow
Solution 13 - BashmorgancodesView Answer on Stackoverflow
Solution 14 - BashMaxFView Answer on Stackoverflow
Solution 15 - BashStewart ScottView Answer on Stackoverflow
Solution 16 - BashnoahView Answer on Stackoverflow
Solution 17 - BashSankarganesh EswaranView Answer on Stackoverflow