MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: Mac OS X Power Hound, Panther Edition

Mac OS X Power Hound Helpful Hints, Part 1

by Rob Griffiths
Running Mac OS X on Windows

Editor's note: Rob Griffiths, author of Mac OS X Power Hound, Panther Edition has hand-picked 16 of his favorite hints and organized them into this two-part series. This week, in part one, you'll discover eight tricks to help your Mac OS X system run smoother and see new ways to personalize your working environment. Examples include activating Exposé with a multi-button mouse, saving iTunes Music Store videos and trailers, and customizing the Dock "poof."

Tip 1-23. Using Apple Help

You might not expect to need help with Help. After all, this built-in, online help system is supposed to be self-explanatory. It's not.

For proof, go to the Finder and choose Help -> Mac Help (or hit Command-?) to open the Help Viewer, as seen below. This simple interface is hiding a ton of detailed information on many of the programs on your machine, but you may not know that--especially if you used prior versions of OS X. Prior to 10.3, Apple provided a "drawer" that showed every application for which you could find help topics. In 10.3, you might think they've done away with this concept, but they haven't--it's just been moved to the Library menu item.


Help Dialog Box

Help serves as the master help system for most OS X applications (excluding various Terminal applications). The theory of bunching up all of your programs' help in one master program is that you can cross-search. If you're in iPhoto, for example, and you're having trouble printing, you might not guess that the Printing topics are in the standard Mac OS X help, not iPhoto help.

Your main interaction with the Help Viewer will probably be through the search box on the toolbar. Type your question in plain English ("How do I print?" for example), and then press Return or Enter to make Help Center find topics that match your query.

The results page contains columns with the topic name, Help Center's estimate of its relevance to your query, and a Location column showing which section of the Help Center contains the topic. You can sort by any of the columns by clicking on the column heading; click twice to reverse the sort order for the selected column.

In the image above, buttons have been added to make the font size larger or smaller, and a printer icon (set off with a separator and surrounded by flexible space) has been included for easy printing. With these simple changes, you'll find the Mac OS X Help not only helpful, but easier to use.

Tip 2-55. Renaming System Folders

Mac OS X gives you lots of freedom in lots of areas, but it's fairly stern about one: you're not allowed to rename any of the key system folders--Applications, Library, and so on--and you really shouldn't rename the pre-installed folders inside of your Home folder (like Movies, Pictures, Documents, and Music). Although OS X will let you change Music to My Music Collection, bad digital things may happen when your programs go looking for folder names that no longer exist--iTunes will no longer be able to find its library unless you tell it the new location. Other programs may not be so accommodating and will just fail when they can't find the Music directory.

Renamed System Files
Renamed system folders

But in fact, you can safely rename any folder, as seen in the picture at right--if you know the secret. The following technique gives you custom names in the Finder only (other programs and their features, like Open or Save dialog boxes, don't show the new names). If you're still game, the ritual goes like this:

  1. In the Finder, open the System -> Library -> CoreServices -> SystemFolderLocalizations folder. Inside, click the en.lproj folder once. This folder contains the file that stores system folders' names. Of course, if English is not your native language, open the folder that matches your language.
  2. Choose File -> Get Info. In the Get Info dialog box, click the triangle next to Ownership & Permissions. The dialog box expands.
  3. Click the small lock icon (so that it appears unlocked). Using the Owner pop-up menu, choose your account name. If a password dialog box appears to confirm that you are indeed an Administrator account holder, enter your password and then click OK. In any case, the point is that you have just seized control of a folder that Mac OS X normally keeps to itself.
  4. Open the en.lproj folder. Inside, you'll find a file called SystemFolderLocalizations.strings. Drag this icon onto the icon of TextEdit. You'll find TextEdit inside of your Applications folder. In any case, you just opened what appears to be a document filled with computer code, starting with this:

    /* Top-level folders */
      "System" = "System";
      "Applications" = "Applications";
      "Library" = "Library";

    What you're actually seeing is a little table. Behind the scenes, Mac OS X maintains a list of the original names of certain folders (on the left side of this table), along with the names you actually see in the Finder (on the right side).

    Again, the name on the left side of each pairing is the actual name of the folder; do not change the left side! You can change the name on the right side to anything you like. So much for the main system folders. What about the folders inside of your Home folder?

    Look for a section heading called Folders in user homes. If you don't see it, you need to add a file named .localized in each folder that you wish to rename (Desktop, Movies, Pictures, and so on).

    You can create these files in Terminal. Open Applications -> Utilities -> Terminal. Type this--touch ~/Desktop/.localized--and then press Enter to add the file to the Desktop folder. Repeat the command with each remaining folder. Log out and log back in. When you reopen the SystemFolderLocalizations.strings file, you now have the Folders in user homes section, which you can edit as described above.

  5. Once you've made all of your edits, save the file. When TextEdit warns you about permissions on the file, click Overwrite to save your changes.
  6. Log out and log back in, open a Finder window, and discover your folders' new vanity plates.

Note: Your custom names won't show up if you have the Finder preferences set to "Always show file extensions." You will also see your custom names when you connect to other machines on the network. Don't worry, you haven't renamed anything on the connected machine; your Mac is simply replacing the names with your preferred versions on your machine only.

Tip 3-18. The Colored Poof

Each time you drag an icon off of the Dock, you're treated to a little animated puff of white smoke. (Never say that Apple didn't benefit from its $500 million investment in the Newton.) But if that's all you want out of life, you're no better than the other downtrodden masses using Mac OS X. Why not use a colored puff of smoke instead--the image at left, when clicked, will play a (brief) movie showing a lightly shaded blue poof in action.

The book demonstrates a completely different shape, so you're not just stuck with a colorized poof!.
The book demonstrates a completely different shape, so you're not just stuck with a colorized poof!

This modification requires a graphics program that can edit PNG files--Photoshop, Photoshop Elements, or Graphic Converter, for example. It also requires some Terminal editing. The first order of business is to create the new graphics that will serve as the replacements for the existing white poof. In a graphics program, create a file that's 128 pixels wide, 640 pixels high, 72 dpi, and has a transparent background. You are going to use this image template to create five images, each in a 128 by 128 pixel square.

If you're using Photoshop Elements, for example, create a grid with 128-pixel spacing (Preferences -> Grid) and then make sure it's visible (View -> Grid). Create each individual image such that it's centered within its own square; this step ensures a smooth animation in your custom poof. Once you've completed your masterpiece, choose File -> Save As, and change the file format to PNG (no interlacing). Save the file somewhere that's easy to find, like your desktop, and name it something obvious like "newpoof.png." At last, you're ready to begin the operating-system surgery:

  1. Open Terminal. At the $ prompt, type the following commands, pressing Enter after each:
      $ cd /System/Library/CoreServices/Dock.app/Contents/Resources
      $ sudo cp poof.png poof_original.png

    Along the way, you'll be asked for your administrator's password. Once you've provided it, Terminal backs up the original file, just in case. (The cp command means copy; the text that follows it specifies which file to copy, and what name to give the duplicate.)

  2. Type sudo cp and then a space. Drag the icon of your new poof off of the desktop and directly into the Terminal window. That's a shortcut that saves you the trouble of typing out its specific "address" on your hard drive.
  3. Type a space, type poof.png, and then press Enter. You've just given your custom poof the correct name and then copied it over the old poof. You're nearly done.
  4. To activate your change, quit the Dock using Process Viewer or the Terminal (by typing sudo killall Dock).

Test your poof by dragging an item out of the Dock. If the Dock isn't working as you'd expect, or if you just want to return to the original poof, open Terminal, type out the first line shown in step 1, press Enter, and then type sudo cp poof_original.png poof.png. When you press Enter, Terminal replaces your modified file with your backup file. After restarting the Dock again, you get the familiar Dock and poof.

Tip 4-11. Activate Exposé With a Multi-Button Mouse

If you have a multi-button mouse plugged into your machine, you can make Exposé even easier to use--by assigning its various modes to the extra buttons on your mouse. The first place to try this is in the Mouse section of the Exposé System Preferences panel--you'll only see this section if you have a multi-button mouse plugged into your system.

You can use the pop-up menus to assign each Exposé action to a mouse button.
You can use the pop-up menus to assign each Exposé action to a mouse button

You may find, however, that setting these values has no effect on Exposé--it just ignores your button clicks. This can happen if your mouse's driver software overrides the settings in the Exposé preferences panel. To work around this problem, you'll need to use the application that came with your mouse to set the Exposé activation keys. But before you go there, change the Keyboard settings for Exposé to something other than the default F9, F10, and F11--add a modifier key or two, such as Shift-Command-F9. If you don't do this, your mouse software may not be of much help, as trying to assign F9 to a button will simply result in Exposé activating.

Open your mouse's preference-setting application (Microsoft Mouse, for instance, is the name of Microsoft's mouse control program), and look for the section where you can set the buttons. Assign F9, F10, and F11 to three available buttons, and then switch back to the Exposé System Preferences pane and set the activation keys back to their default values--otherwise, your mouse assignments won't do anything, as F9, F10, and F11 will be undefined! Once you've got everything set up, Exposé's power will never be more than a spare mouse click away!

Tip 5-18. Storing Apple Software Updates

Software Update has another annoyance. If you ever reinstall Mac OS X from its original CD or DVD (when you put in a new hard drive or move to a new computer, for example), you'll have to download and install all relevant updates again. With this hint, you can't skip the reinstallation process completely, but you can skip the download step. Preserving updates on your hard drive is easy enough. Each time Software Update finds updates to install, turn on the ones you wish to install and then choose Update -> Install and Keep Package, as shown in the figure below. If you prefer, you can also use Update -> Download Only, and install the update later at your convenience.

Preserving updates on your hard drive is easy enough.
Preserving updates on your hard drive is easy enough

The downside to this method: when there are multiple updates that require restarting your Mac, you must restart after each one you install. On its own, Software Update would save up its one restart until all of the updates were installed.

This method is also a good one to use if you work in a lab, or other environment with a bunch of Macs--it's much easier to download once and install many times, rather than downloading multiple copies of the same 50MB system update.

Tip 6-4. Use .Mac Slideshow Images as Desktop Backgrounds

One of the cooler features of the .Mac service is the ability to create a public slideshow directly from iPhoto--just select an album and click the .Mac Slides button. After iPhoto finishes uploading your images, you can tell anyone who has Mac OS X 10.2 or newer your .Mac name. Subsequently, they can use your slideshow as a screen saver by selecting .Mac in System Preferences (in the Desktop & Screen Savers pane in 10.3, or the Screen Effects pane in 10.2), as seen in the figure below.

Anyone can use your slideshow as their screen saver by selecting .Mac in System Preferences
Anyone can use your slideshow as their screen saver by selecting .Mac in System Preferences

One of the challenges of this feature, though, is trying to find public slideshows to use with it; unless all of your friends and relatives are fellow .Mac types, you may find the selection to be quite limited. This is where dotmac.info comes in, since it has a section devoted to nothing but public .Mac slideshows (click Browse Slide Shows). Look through the collections, then enter the associated .Mac user name into System Preferences for those you'd like to use.

Viewing .Mac screen savers can be quite relaxing, but your machine must be idle for you to enjoy their benefits. Wouldn't it be nice if you could use some of the images for your desktop background, too? Well, it turns out that you can do just that. Switch to System Preferences -> Desktop & Screen Saver -> Desktop tab and click Choose Folder from the list of screen savers. In the resulting dialog box, navigate to your Home -> Library -> Caches -> com.apple.iToolsSlideSubscriptions folder.

This folder holds all of the public slideshows that you're currently subscribed to, organized by .Mac user name. Select the name of the user whose slideshow you'd like to see on your desktop, click the Public Slide Show folder, then click Choose. Finally, turn on the Change Picture checkbox. You can now enjoy the public slideshow as an ever-changing desktop image that you can see, even while you work.

Note that you can also copy the images out of the Caches folder to keep them for future use--but be aware of copyright issues. The copyright on the images is owned by the .Mac user who published them, so you can't simply copy their work and use it as you wish! If you want to do anything beyond using an image on your own machine, you'll need permission from the original .Mac publisher first!

Tip 7-12. Force Messages into Plain Text Mode

When email was still a fresh, new thing (you know, about 15 years ago), all messages were sent in "plain text" mode. A plain text message contains no graphics, sounds, different font faces, colored backgrounds, or any other distractions--just the message, typically displayed in a typewriter-looking monospaced font such as Monaco. Only as email matured would it gain the aforementioned distractions (marketers call them "enhancements").

If you prefer your email the way the Net intended, you've probably searched Mail's preferences high and low for a plain-text-only setting but come up empty-handed. The closest you can come is to turn off the "Display images and embedded objects in HTML messages" setting in the Viewing section of Mail's preferences. (This setting is also an effective way to make sure that spammers can't use embedded images to collect information about your Mail viewing habits. Embedded images can be used to verify that you have opened their messages, thereby insuring a continued flow of spam into your inbox.)

It turns out, though, that you can force nearly all of your inbound messages into plain text mode. Make sure Mail isn't running, then launch the Terminal (in Applications -> Utilities) and type this (hit Return at the end):

defaults write com.apple.mail PreferPlainText -bool true

When you launch Mail again, you'll find that most of your messages are now displayed in glorious plain text. The only exceptions will be messages that are sent with only HTML content. When you think about it, since there's no plain text alternative, there's no way Mail can force a plain text display. If you ever feel like rejoining the modern era, quit Mail, launch the Terminal, and repeat the above command, but replace true with false.

Tip 8-16. Save Videos and Trailers After Viewing

The iTMS movie trailers and music videos are often high-quality, large videos that can be fun to watch repeatedly. However, the way the store works, once you've downloaded and watched a video, it's basically gone. If you want to watch it again, you'll have to download it again, and there's no apparent way to save it. Downloaded videos and trailers, however, are actually stored for a while on your hard drive. They're in a hidden folder that gets erased each time you reboot your machine. With the help of AppleScript, you can copy these videos from the hidden folder to your desktop, making it easy to keep them for future viewing.

Open Script Editor (in Applications -> AppleScript), and enter the following text (alternatively, just click this link and the script should magically appear in a new Script Editor document):

set originalFile to do shell script "lsof -wa -Fn -c iTunes 
  +D /tmp | grep -i QTP | head -1 | cut -c 2-"
if length of originalFile is greater than 0 then
  set newFile to POSIX 
  path of (choose file name default name "iTunes Video.mov")
  if length of newFile is greater than 0 then
    if newFile does not end with ".mov" then set newFile to 
      newFile & ".mov"
    do shell script "/bin/cp -v '" & originalFile & "' '" & 
      newFile & "'"
    do shell script "/Developer/Tools/SetFile -t 'MooV' -c 
      'TVOD' '" & newFile & "' || true"
  end if
else
  display dialog "No movie found. Please make sure that 
  the movie is currently visible in iTunes." buttons 
  {"OK"} default button "OK"
end if

Note: The "" characters are used in AppleScript to indicate the continuation of a line. Do not enter them when you see them here. Instead, type the next line as a continuation of the line containing the "" symbol. Click the Compile button to insure you didn't make any typos, and then use File -> Save to save your script. In the Save dialog box, set the File Format to Application, and check the Run Only box. Name the script whatever you want, then save it into your Documents folder (or some other easy-to-find location). Quit Script Editor.

Now visit the iTMS, find a video or trailer you'd like to keep, and let it completely download. While the iTMS window is still open, switch to the Finder and double-click your new script. After a brief delay, you should see a Save dialog box; enter a name and pick a folder to store it in, then click OK. The script will find the movie, rename it, and copy it to your destination. Furthermore, it'll make sure the type and creator values are set properly for QuickTime to play the video.

Note: This script requires that you have the XCode Developer Tools installed. If you don't have the tools, you can still use the script--just remove the line that begins with do shell script "/Developer/Tools/SetFile -t. You may then have to open the movie directly from QuickTime or use another tool to set the type and creator codes.

Rob Griffiths is the creator of the Mac OS X Hints site, a database of over 3,500 tips on using OS X.


Return to MacDevCenter.com.

Copyright © 2009 O'Reilly Media, Inc.