Read Mac Hacks Online

Authors: Chris Seibold

Tags: #COMPUTERS / Operating Systems / Macintosh

Mac Hacks (13 page)

BOOK: Mac Hacks
5.25Mb size Format: txt, pdf, ePub
ads
Extending the Hack

This hack focused on creating a web page on your Mac, but you
don’t have to use No-IP just to share web pages. You can put a variety
of files in your Sites folder and then use No-IP to access them while on
the move. For example, say you want to listen to your 14,001 favorite
songs, but that’s one song too many for your iPod touch! If you tossed
that song in your Sites folder, you could play it over the Internet by
typing the name of your website into a browser and appending
/nameofsong.mp3 on the end. For example, if your website is
www.dawnofmanslegos.no-ip.org and you added
themefromtron.mp3
to your Site folder, to hear the
song on the go, you would head to
www.dawnofmanslegos.no-ip.org/themefromtron.mp3.

Hack 16
. Change the Startup Sound

Push
the power button, get the noise! That’s the way it’s been
on Macs forever—but it doesn’t have to be that way any longer. This hack
shows you how to automatically silence the chime and play a different
sound.

If you were one those people who was into Macs before they were
cool, someone who sincerely believed that OS 9 was the superior operating
system of the day, you’ve been using Macs long enough to get tired of the
startup sound. Or maybe you don’t dislike the sound, but you have a
legitimate reason to want it gone: you want to start your Mac up without
waking your roommate, say, or you might be making one of those soufflés
that fall with the merest of sonic vibrations.

Whatever your reason, you can get rid of the startup sound. But just
silencing the chime isn’t very hard or interesting, so what if we amped up
the interest level by silencing the chime
and
adding
a new sound? The silencing part is easy, but the process of getting your
Mac to play a different startup sound is a bit more kludgy.

First, let’s get rid of the sound altogether. To pull this off,
you’ll need the following tools:

  • A finger or stick

  • The ability to remember to push a button

That doesn’t seem like a lot to ask, does it? But it turns out it
actually is. Because with this method, you mute the startup chime by
remembering to push the mute button on the keyboard (using your finger or
that stick)
every single time
you shut down or
restart your Mac. Forget to push the mute button when you’re shutting down
and the sound will play as your Mac starts up.

“That’s not much of a hack,” you might be saying, “That’s barely
even a tip!” You want something that takes care of muting the chime
automatically! Don’t give up—we’re going to get this worked out and make
the process either super easy or fairly complex.

Turns
out there’s an application that gives you the ability to
control the startup sound. Download the
Psst app
, which controls
the startup sound’s volume so you don’t have to. Sadly, it doesn’t work on
every
Mac—there’s a list of supported models on
Satsumac
—but it seems to work for
most setups.

Once you download Psst, expand the
.dmg
file
and then drag the app’s icon to the Applications folder. Then fire up
Psst. Once you do, you’ll see a Start Psst button; click it and then
adjust the slider to control the volume of the startup chime. To disable
Psst, simply launch the program
again and click Stop Psst (
Figure 3-9
). It really is that
simple.

Figure 3-9. Psst is a minimalist app that does only one thing: lets you
control how loud the startup chime is on your Mac. That may not seem
like a big deal...until you have to start your Mac in a library or other
quiet place.

That takes care of killing the start chime, but this hack also
promised to explain how to add a new sound when your Mac starts. First the
bad news: to
really
change your Mac’s startup sound,
you’re going to have to do some serious
work.

People
debate where the startup sound actually resides; some aver
it’s hidden somewhere on your hard drive, while others say it’s in the
logic board’s ROM. To test the hard drive theory, your humble author
opened a Mac Pro and removed the hard drives; when the Mac Pro was
restarted, the startup chime still sounded. Conclusion: the sound isn’t on
the hard drive, which means it’s hard to replace. You could, one supposes,
dump the ROM, edit it, and then burn it back to the chip or perform some
other incredibly complex process not worth messing with.

Fortunately, you can make your Mac use a different startup sound
with just Automator and Login Items. (There are probably a million other
ways to do this, but this method has been tested and works. The one caveat
is that this method doesn’t result in the new sound playing at the exact
same point in the startup cycle that the standard chime does; instead, it
plays once your desktop appears onscreen.) But before we get started with
that, head to iTunes and create a new playlist with a name you can
remember (Startup Sound, perhaps). Then choose the sound file you want
your Mac to play and add it to that playlist.

Now
we’ll use Automator to create a super simple application to
play that sound (or song). Launch Automator, click the Application icon,
and then click Choose. Next, in the Library column on the left side of the
window, choose Music. When you do that, you’ll get a whole pile of options
in the middle column; there, choose Get Specified iTunes Items and drag it
into the pane on the right side of the Automator window. You’ll see a cool
representation of the Get Specified iTunes items you just chose. Click Add
and, in the menu that drops down, select the playlist you created earlier
(
Figure 3-10
).

Figure 3-10. Adding the playlist we created earlier. This will serve as your
new startup sound.

Back in the Automator window’s center column, choose Play iTunes
Playlist and drag it underneath Get Specified iTunes Items in the
righthand pane (
Figure 3-11
). That’s about all
there is to it. Click the Run button in the window’s upper-right corner to
test out your creation. You might see a warning that the application won’t
receive input when run inside Automator, but you can ignore it. Automator
will then run the application you created—you’ll see green checkmarks
appear in the log pane and hear your chosen file play!

Turns
out all the hard work is done. All we have to do now is
save the creation as an app, and then add that to the Login Items for your
user account. In Automator, choose File→Save and give your creation a
name. After making sure you’re saving it as an
app
(choose Application in the File Format pop-up menu), hit Save.

Figure 3-11. Automator will run your application through its paces. The green
checkmarks mean everything is going as expected. If you look closely in
the Log section, you can even see how long each step took.

Now to finish off this hack, open System Preferences and choose
Users & Groups. You can’t do much without authenticating, so click the
little lock in the window’s lower-left corner and type your password. Now
that you have the power, click the user account you want to spice up with
the new sound, and then click the Login Items tab. In the Login Items
pane, click the + button and navigate to the application you just created.
Double-click the app and it’ll get added as a startup item. (If you want
iTunes to stay hidden, check the box in the Hide column; otherwise you’ll
be greeted by the full iTunes
window.)

That’s it—you’re done! Now the process of shutting down and starting
up your Mac goes like this: when you shut down or log out, the volume is
muted (or changed to whatever you set with Psst). When you start your
machine again, the volume is turned back to the level you set it at before
you shut down, and your new sound plays after your desktop shows up—all
with no intervention from you!

Using Terminal Commands: A Better Way?

Downloading Psst and whipping up an application to change the
startup sound gets the job done, but it seems a little convoluted and
the sound plays pretty late in the startup experience. Could the
Terminal offer us a superior result and experience? Anyone who has tried
the hack will tell you with confidence that the answer is “yes.” So
let’s get started.

We’ll be using the Terminal for the rest of this hack so if that
gives you the willies, check out
Chapter 6
before
you begin.

Feeling comfortable? Great! Open Terminal and type:

sudo nano /system/library/muteon.sh

Here’s
what that code means:

  • sudo
    is short for
    “superuser do.” Basically, this tells your Mac that you’re the boss
    and it has to listen.

  • nano
    starts up Nano, a
    built-in Terminal program for text editing.

  • /system/library/
    tells Nano
    where to write the file. You don’t have to save the file there, but
    it’s an easy location to use.

  • muteon.sh
    is the file
    you’ll create with Nano. The
    .sh
    means it runs in Bash, the shell for OS X.

Now that you know nothing bad will happen, hit Return to run the
command. You’ll likely be asked for your password; type it in and hit
Return. When you do, something odd will happen: Terminal will switch to
the Nano environment (
Figure 3-12
).

You’re using Nano! Now type:

#!/bin/bash
osascript -e
'set volume with output muted'

What
does all that mean?:

  • #!
    is called a shebang, and
    it tells the interpreter to run this file.

  • /bin/bash
    is just the path
    to the interpreter.

  • osascript
    tells the
    interpreter to use AppleScript.

  • The
    –e
    flag lets everyone
    know the next thing you type is either a statement or a program
    file. In this case, it’s the statement
    'set
    volume with output muted'
    , which tells AppleScript to mute
    your machine’s volume.

Figure 3-12. The Terminal’s Nano text editor. You’re still using Terminal,
but the window looks a little different because Nano is designed to
make text editing in Terminal a little easier.

Press Ctrl-O and then the Return key to save what you just typed.
(Nano writes all this to a file that you can see, if you desire, by
heading to
Computer/Startup
Disk
/System/Library
as shown in
Figure 3-13
.) Then Exit Nano by
hitting Ctrl-X.

Figure 3-13. You created this file with Terminal but that doesn’t make it
magic—it’s a file just like any other. If you want to poke at it with
a GUI text editor, you’re free to do so.

That takes care of turning the volume off so the startup chime
won’t sound, but we also want the volume
back on
after the computer boots. That means another script, but since you are
familiar with the first one, this one will be easy to follow because
it’s really similar. In Terminal, type:

sudo nano /system/library/muteoff.sh

In the Nano window that appears, type:

#!/bin/bash
osascript -e
'set volume without output muted'

Then press Ctrl-O followed by Return to save, and then Ctrl-X to
exit Nano.

The necessary scripts are now in place, but we have to make them
executable. In Terminal, type:

sudo chmod u+x /system/library/muteon.sh

It’s useful to know exactly what’s going with this command:

  • As you know,
    sudo
    grants
    you superuser privileges.

  • chmod
    is short for “change
    mode”—in this case, we’re changing the file to an executable.

  • u
    tells chmod to add you as
    a user, and
    x
    tells chmod to make
    the file executable.

  • /system/library/muteon.sh
    is the path to the file you want to change.

Now that that is taken care of, you’ll need to do the same thing
to the
muteoff
file by typing:

sudo chmod u+x /system/library/muteoff.sh

We’ve got the necessary files in place, but the system doesn’t
know about the files. We need to let the system know to look for them so
that your Mac knows you’ve provided instructions for it to follow.
To
do that, OS X lets you use login and logout
hooks—
ways to
get your Mac to play a script (like the two you just created) when you
log in or out. Chances are that you haven’t messed with adding hooks
before, but if you’re wondering what you did that very blurry night you
watched the
Lord of the Rings
trilogy and took a
drink every time anyone walked somewhere, it’s easy to check whether you
have any hooks already installed. In Terminal, type:

sudo defaults read com.apple.loginwindow LoginHook

Similarly for the logout hook:

sudo defaults read com.apple.loginwindow LoginoutHook

If you don’t find any hooks (you’ll see a message that ends with
“does not exist”), you’re free to add your own. Even if you
do
find hooks, you can still overwrite them if you
are so inclined. To do so, type the following in Terminal:

sudo defaults write com.apple.loginwindow LogoutHook /system/library/muteon.sh

And one to turn the sound on again:

sudo defaults write com.apple.loginwindow LoginHook /system/library/muteonff.sh

That’s it: your Mac turns on without the chime! Wait—something’s
missing. We also wanted your Mac to play a different sound when it
started. No problem. Using the stuff we learned earlier, we’ll set up a
script to do that:

sudo nano /system/library/playsoundfirst.sh

As before, Nano will fire up. In Nano, type:

#!/bin/bash
afplay your
file
'
s name goes here

Like
the scripts we wrote earlier, this text will invoke a
command. In this case, afplay will play the file of your choosing. You
can either drag the file you want afplay to play into the Nano window
(as shown in
Figure 3-14
) or type the path
to the file. You’re free to choose
.mp3
,
.aiff
, and plenty of other file types; just pick
something you want to hear. Then save with Ctrl-O followed by Return,
and exit Nano with Ctrl-X.

Figure 3-14. Don’t choose a long-playing file for your startup sound. For
example, choosing Car Talk (as shown here) is a guaranteed
mistake.

Warning: Pick the file you want to hear very carefully because
your Mac will be unresponsive while the file is playing. This isn’t a
big deal if you pick a system sound, but if you pick an hour-long
podcast, you’ll regret your choice!

Now we need to make this file executable by typing:

sudo chmod u+x /system/library/playsoundfirst.sh

As before, we have to use a hook to tell the command when to
run:

sudo defaults write com.apple.loginwindow LoginHook /system/library/playsoundfirst.sh

That’s it—you’re completely done. No more startup chime
and
you get a new sound that either plays as soon
as you type in your password (on a multiuser machine) or before the
desktop shows up (on a Mac with automatic login
enabled).

BOOK: Mac Hacks
5.25Mb size Format: txt, pdf, ePub
ads

Other books

Cruising Attitude by Heather Poole
Shelter from the Storm by Gill, Elizabeth
Lady Barbara's Dilemma by Marjorie Farrell
David Bowie's Low by Hugo Wilcken
We Know It Was You by Maggie Thrash
Finding Cassie Crazy by Jaclyn Moriarty
The Tenth Gift by Jane Johnson