One of the fun features of earlier Mac operating systems (System 9.x and earlier) was the ability to assign sound files to play at startup, shutdown, or other specific events. My Mac used to greet me every morning. It also played a Three Stooges sound file of Curly saying, "I'm trying to think but nothing happens" whenever it presented an error dialog box.
While I haven't found a way to assign a sound effect to a specific event in OS X, it is fairly easy to set a sound to play when your Mac starts up. To do this, we'll use Automator to create an application wrapper around a Terminal command to say a phrase or play a sound file. Once we create the application with Automator, we can assign that application as a startup item.
So, let's get going with our project to add a startup sound to your Mac.
- Launch Automator, located at /Applications.
- Select Application as the template type to use, and click the Choose button.
- Near the top left corner of the window, make sure Actions is highlighted.
- From the Actions Library, select Utilities.
- Click and drag "Run Shell Script" to the workflow pane.
- The shell script we want to use depends on whether we want the Mac to speak specific text using one of the available built-in voices, or play back an audio file that contains music, speech, or sound effects. Because there are two different Terminal commands involved, we'll show you how to use both of them.
Speaking text with the Mac's built-in voices
We've actually already covered a way to get a Mac to speak using Terminal and the "say" command. You can find instructions for using the say command in the following article:
Take a moment to investigate the say command by reading the above article. When you're ready, come back here and we'll create a script in Automator that uses the say command.
The script we'll add is pretty basic; it's in the following form:
Say -v VoiceName "Text you want the say command to speak"
For our example, we're going to have the Mac say "Hi, welcome back, I've missed you" using the Fred voice.
To create our example, enter the following into the Run Shell Script box:
Say -v fred "Hi, welcome back, I've missed you"
Copy the entire above line and use it to replace any text that may already be present in the Run Shell Script box.
A few things to note about the say command. The text we want the Mac to speak is surrounded by double quotes because the text contains punctuation marks. We want the punctuation marks, in this case, commas, because they tell the say command to pause. Our text also contains an apostrophe, which could confuse Terminal. The double quotes tell the say command that anything within the double quotes is text and not another command. Even if your text doesn't contain any punctuation, it's a good idea to surround it with double quotes.
Playing back a sound file
The other script we could use to play back a sound file uses the afplay command, which instructs Terminal to assume the file following the afplay command is a sound file, and to play it back.
The afplay command can play back most sound file formats, with the notable exception of protected iTunes files. If you have a protected iTunes music file you wish to play, you must first convert it to an unprotected format. The conversion process is beyond the scope of this article, so we'll assume you wish to play a standard unprotected file, such as an mp3, wav, aaif, or aac file.
The afplay command is used as follows:
Afplay path to sound file
You could use afplay to play back a long music track, but remember that you'll hear the sound every time you start your Mac up. A short sound effect is better; something under 6 seconds is a good target.
You can copy/paste the above line into the Run Shell Script box, but be sure to change the path to the correct sound file location on your system.
Testing your script
You can perform a test to make sure your Automator application will work before you save it as an application. To test a script, click the Run button in the top right corner of the Automator window.
One of the most common problems is an incorrect file path name. If you're having difficulty with the path name, try this little trick. Delete the current path to your sound effect file. Launch Terminal, and drag the sound file from a Finder window into the Terminal window. The file's path name will display in the Terminal window. Simply copy/paste the path name to the Automator Run Shell Script box.
Problems with the say command are usually caused by not using quotes, so make sure to surround any text you want your Mac to speak by double quotes.
Save the application
When you're verified that your script is working properly, select "Save" from the File menu.
Give the file a name, and save it to your Mac. Make a note of where you saved the file, because you'll need that information in the next step.
Add the application as a startup item.
The last step is to add the application you created in Automator to your Mac user account as a startup item. You can find instructions on how to add startup items at:
That's all there is to adding a startup sound to your Mac.