Mac OS X (Tiger and Leopard) Configuration Tips


I add items to this list when I discover configuration tips that I personally find useful. It is not meant to be a comprehensive list of everything you can do to customize OS X; it is mainly a record so I remember what customizations I've performed, so I can potentially undo them later and/or repeat them on new computers or after major OS upgrades. Good resources for more Mac OS X configuration tips are macosxhints, lifehacker, secrets, and (somewhat less frequently) the official Apple Support site – most of the tips I've listed here were either found at one of those sites initially or have ended up archived there later.



My current operating system is Mac OS X 10.5.8 (Leopard) with (Apple standard) X11/Xquartz 2.1.6


(I do not plan to upgrade to OS X 10.6 (Snow Leopard) in the near future, until after I have had a chance to read more user feedback about it and test it myself on a non-crucial computer.)

Here are the steps I follow to configure a new Mac.

Want to tweet this URL? Use http://tinyurl.com/dwhmactips







Recover when X11 freezes while scrolling


Problem: When using an xterm or other X11 program (e.g., vim), aggressive (i.e., rapid and/or continuous) scrolling with the middle mouse wheel can cause X11 to freeze. This is a known bug in the Apple X11 software.


Solution 1:

  1. Start the Terminal application and issue the command:   killall -STOP X11

  2. Use the mouse to move the cursor into any open X11 window, and click to select. Note that this will not produce any noticeable effect (except possibly the spinning color wheel).

  3. Return the cursor to the Terminal window, and issue the command:   killall -CONT X11

  4. This process has the disadvantageous side effect that if you are using a third-party virtual desktop manager, then all existing X11 windows will be gathered onto the current desktop.

Solution 2:

  1. Start the Activity Monitor application, and open the main activity monitor window if it does not open by default (Cmd-1 or Window→Activity Monitor).

  2. Select the X11 task in the activity monitor window, then run the View→Sample Process function. You might need to repeat the Sample Process function several times.

Solution 3: If all else fails, then select Apple→Force Quit, and kill the X11 program. WARNING: this will lose changes to any unsaved files.


OS Version Compatibility: Tiger; untested in Leopard, but probably works. It's possible that this issue was fixed in 10.4.3+ and/or that it only occurs when using a Logitech USB mouse. During several years of running 10.5+, this issue has not reoccurred.


Back to the top...



Change the default login shell


Problem: The “factory set” default login shell for Mac OS X (Panther+) is bash. Some (misguided!) users may wish to use other shells (e.g., tcsh is popular).


Tiger Solution: To change the default shell for a particular user account, use the application utility Netinfo Manager. Under the “users” category in Netinfo Manager, look for the desired login name and find the “shell” item in the list of properties for that account. This should say /bin/bash by default; modify it to the desired shell (e.g., /bin/tcsh). This will require first unlocking the properties by clicking on the lock icon and entering an administrator-level password. Quit Netinfo Manager, then log out of the user account and log back in to globally initialize the new default shell.


Leopard Solution: The application utility Netinfo Manager no longer exists in Leopard. Instead, open the Accounts preferences in System Preferences. Unlock the preferences by clicking on the lock icon in the lower left corner of the preferences panel and entering an administrator-level password. Then right-click (or control-click) on a user name and select the Advanced Options menu. Select the desired login shell from the pull-down menu, and click on OK. Log out and back in to put the change into effect.


A. Lorber pointed out to me that in order to change the default login shell, your chosen shell must also be listed in the file /etc/shells, which OS X consults to determine what is a valid shell. By default, /etc/shells contains the following entries:

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh 

If you want to use a different shell from these as your default login shell, then you must edit /etc/shells to include the full path to the installation of the shell on your computer (e.g., /opt/local/bin/bash). Editing /etc/shells requires an administrator-level password.


OS Version Compatibility: Tiger and Leopard, with different procedures (see above).


Back to the top...



Set iChat to automatically accept incoming video invitations


Problem: You want iChat to automatically accept any incoming video chat invitation. This can be useful for keeping an eye on things at home when you are away (what are my cats doing right now?) or to help out less technologically savvy people (e.g., grandma). In AIM, this is a standard preferences settings, but in iChat it does not show up in the Preferences menu.


Solution: This does exist as an iChat preferences setting, but it is a hidden preference. Issue the following command in a Terminal or xterm (X11) window:

defaults write com.apple.ichat AutoAcceptVCInvitations 1

Repeat with “1” replaced by “0” to turn it off. The file modified by defaults in this case is ~/Library/Preferences/com.apple.iChat.


OS Version Compatibility: Tiger; untested in Leopard, but probably works.


Back to the top...



Make focus follow mouse in Terminal


Problem: By default, mouse focus for Terminal is determined by clicking on the desired window, but it is often more convenient to have the focus automatically follow the mouse to any window.


Solution: Issue the following command in a Terminal window and then restart Terminal:

defaults write com.apple.terminal FocusFollowsMouse -string YES

Repeat with “YES” replaced by “NO” to turn it off. The file modified by defaults in this case is ~/Library/Preferences/com.apple.Terminal.plist.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Make focus follow mouse in X11 (using quartz-wm)


Problem: By default, mouse focus in X11 is determined by clicking on the desired window, but it is often more convenient to have the focus automatically follow the mouse to any window.


Solution: Issue the following command in an xterm (X11) window and then restart X11:

defaults write com.apple.x11 wm_ffm -bool true

Starting with Leopard 10.5.5 (which upgraded X11 to 2.1.5), this is changed to:

defaults write org.x.X11 wm_ffm -bool true

Repeat with “true” replaced by “false” to turn it off. The file modified by defaults in this case is ~/Library/Preferences/com.apple.x11.plist ~/Library/Preferences/org.x.X11.plist.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Enable click-through in X11 (using quartz-wm)


Problem: Clicking on an unfocused X11 window (if you have not enabled “focus follows mouse”) or clicking on an X11 window when X11 is in the background will only focus the X11 window in the case of a left click. However, any additional action implied by a click (e.g., using a middle click to paste text selected in another X11 window - if focus follows mouse is not enabled - or selected and copied in a non-X11 window) will not be performed and the click will not activate the window.


Solution: Issue the following command in an xterm (X11) window and then restart X11:

defaults write com.apple.x11 wm_click_through -bool true

Starting with Leopard 10.5.5 (which upgraded X11 to 2.1.5), this is changed to:

defaults write org.x.X11 wm_click_through -bool true

This feature allows the action implied by the click to be passed through to the application.

Repeat with “true” replaced by “false” to turn it off. The file modified by defaults in this case is ~/Library/Preferences/com.apple.x11.plist ~/Library/Preferences/org.x.X11.plist.


Note that focusing or activation of the X11 window will only happen if the click would normally have focused or activated the window. For example, a left-click (or equivalent) will normally activate an X11 xterm window, whereas a middle click (or equivalent) will not. However, with click-through enabled, a middle click on an unfocused or backgrounded (i.e., inactive) X11 xterm window will perform the expected action of pasting whatever is in the copy buffer into the xterm window, but will not activate it (i.e., will neither focus the xterm window nor bring X11 to the foreground).


The following odd behavior with click-through in X11 appears to be fixed as of Leopard 10.5.5 with X11 2.1.5

Some confusing click-through behavior found in Leopard 10.5.4 with (Apple standard) X11 2.1.1: A click-through event cannot constitute the very first command issued into an xterm window whose initiation started X11. You must at least once manually click to activate the xterm window (or any other X11 window currently running) before click-through will subsequently be enabled. For example, if you type "xterm" in a Terminal window to start X11 and instantiate an xterm window, then immediately click back onto the Terminal window, highlight the text “xterm” using the left mouse button (or equivalent), then try to click-through paste it into the xterm window using the middle mouse button (or equivalent), then nothing will happen. However, if after starting X11 and the xterm window, you click on a non-X11 window (like a Terminal window) to put X11 in the background, then click on the xterm window to put X11 in the foreground, then again click to a non-X11 window (like a Terminal window) to put X11 in the background, then any subsequent click-through paste will transfer the contents of the copy buffer into the xterm window command line as expected.

OS Version Compatibility: Tiger and Leopard.


Back to the top...



Configure a large xterm window in X11


Problem: The default xterm window in X11 is small with a very tiny font.


Solution: Use the following command from the X11 Applications menu or the command line:

xterm -fn 10x20 -geometry 80x21 -sb -sl 1500 -vb -bg white

OS Version Compatibility: Tiger and Leopard.


Back to the top...



Change the highlight color in Preview


Problem: The highlight color in the Preview application is difficult to see; also, search terms don't appear to be highlighted in the viewed document.


Solution: Issue the following command in an xterm (X11) or Terminal window and then restart Preview:

defaults write com.apple.Preview AppleHighlightColor "0.9137 0.7216 1.0"

The three numbers range from 0.0–1.0. The values shown here produce light purple. To find the values for a particular color, set the system-wide highlight color using the Appearances panel in System Preferences, then view the AppleHighlightColor setting in ~/Library/Preferences/.GlobalPreferences.plist.


After executing a search in Preview, press Tab to shift the focus into the main window and highlight the search term with the selected color. Then press Cmd-G to jump forward through selected search terms using the selected highlight color.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Run the Mac OS X maintenance scripts


Problem: Mac OS X is a UNIX-based system, built specifically on FreeBSD. UNIX systems run scheduled maintenance routines to clean up a variety of System logs and temporary files. By default, these are executed between 03:15 and 05:30 local time, depending on the script. If your Mac is shut down or in sleep mode during these hours, the maintenance scripts will not run. This results in log files that will grow over time, consuming free space on your Mac OS X startup disk. If your Mac is shut down or left in sleep mode overnight, you should invoke these maintenance routines manually on a regular basis.


Solution: Manually running the maintenance scripts – Using an administrator-level account, you can execute all three maintenance scripts at once by issuing the following command in a Terminal or xterm (X11) window.

sudo periodic daily weekly monthly

All three scripts will run in sequence. There is no visual feedback while the scripts execute.


Determining when the maintenance scripts last ran – You can check the date and time stamps of the log files associated with each maintenance script, which indicates when the scripts were last executed. Use the command

ls -al /var/log/*.out

The maintenance performed by the scripts – Each maintenance script has a specific function.



OS Version Compatibility: Tiger and Leopard.


Back to the top...



Fix garbled fonts


Problem: Fonts in PDF or postscript files appear fine on screen, but are garbled when printed.


Solution:

  1. Close all applications

  2. Delete the /Library/Caches/com.apple.ATS folder

  3. Immediately restart the computer

This removes system font cache files that can become corrupted.


OS Version Compatibility: Tiger; untested in Leopard, but probably works.


Back to the top...



Set view options for the Desktop


Problem: The Desktop can become crowded with icons. Which one is a PDF file? Which one is an image? Where's that file I just downloaded? I don't know! Help me!


Solution: Right-click (or control-click) in the Desktop background, then select Show View Options. The options for Show Icon Preview and Keep Arranged By Kind are especially useful.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Rotate individual PDF pages in Preview


Problem: Some PDF files contain a mix of portrait and landscape pages. Preview contains obvious functions (Rotate Left or Rotate Right in the Tools menu or on the toolbar) that will rotate all of the pages from one format to the other, but how can you rotate only certain pages?


Solution: Hold down the option key before selecting Rotate Left or Rotate Right to rotate only the current page. If you save the document after applying the selective rotations, it will also save the rotations.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Use cron to schedule automatic tasks


Problem: How can I schedule some tasks (like backing up one disk to another) to occur automatically on a regular basis?


Solution: The standard UNIX command cron will manage the execution of tasks on a specified schedule. The first step is to create a command-shell script that executes the desired task. For example, I use a bash script containing an rsync command that backs up the contents of my main hard drive to a secondary hard drive. Store this shell script somewhere in your home directory (the home directory on a Mac is at /Users/{login name}); for example, I want this script to be executed daily, so I created a hidden sub-directory in my home directory called .cron.daily/ and put the script file in it.


Tasks for cron to execute are listed in a crontab file. System-wide (i.e., root level) cron tasks are controlled by /etc/crontab, but for user-level tasks, a crontab file (or, in my case, a hidden .crontab file) can be created in the home directory. The format of the crontab file is like this:


#minute hour mday month wday command
 1503***sh /Users/{login name}/.cron.daily/backup.sh
 15031**sh /Users/{login name}/sample1.sh
 1503**6sh /Users/{login name}/sample2.sh
 */15****sh /Users/{login name}/sample3.sh

The first line of the crontab file is a commented header line (indicated by a leading #). The specified tasks begin on the second line. Entries in columns are separated by tabs. In this example, the command in the first task line (to execute my disk backup script) is executed at 03:15 (i.e., 15 minutes after 3am) on every day of the week (wday) for every day (mday) of every month (month). The asterisks are read as “every”. As further examples, the second task line would execute its command at 03:15 only on the 1st day of every month. The third task line would execute its command at 03:15 on the 6th day of every week. The fourth task line would execute its command every 15 minutes.


Allowed values for the crontab parameters are 0–59 for minute, 0–23 for hour, 1–31 for mday, 1–12 for month, and 0–7 for wday (0 and 7 are Sunday). The month and wday values can also be specified using the first three letters of the month or day name (e.g., “Jan” for January or “Thu” for Thursday). Ranges and (comma-separated) lists are allowed. For example, 8–11 in the hours column would run the associated command at hours 8, 9, 10, and 11. A list of 1,2,5,9 in the hours column would run the associated command at hours 1, 2, 5, and 9.


Once the crontab file and the associated script file(s) have been created and stored in the specified locations, you must initiate the cron process by issuing the command

crontab /Users/{login name}/.crontab

(substitute your own name for your crontab file). The command

crontab -r

will stop the execution of cron tasks. The command

crontab -l

will list all of the currently scheduled cron tasks. I have found that cron will occasionally stop on its own (possibly associated with incremental software updates to the operating system), so it is a good idea to run crontab -l occasionally to make sure that your cron tasks are still running.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Change the default web browser


Problem: I don't want to use Safari as my default web browser (e.g., for downloading URL-linked attachments in emails). How can I change the default web browser?


Solution: Start Safari. Type Cmd-, or select Safari→Preferences. In the Preferences window, select the General tab, then find and select the desired web browser under the Default Web Browser pull-down menu. This will change the default web browser for all applications.


OS Version Compatibility: Tiger and Leopard.


Back to the top...



Make printers exit after finishing


Problem: Under Tiger (and earlier versions), when a print job finished, the printer utility would automatically quit and the associated icon would vanish from the Dock. Under Leopard, the default behavior is for the printer utility to remain active, with its icon in the Dock. How can I make the Leopard printer utility quit when it is done printing?


Solution: Right-click (or control-click) on the printer icon in the Dock and select “Auto-quit when done” to restore Tiger-like behavior. This apparently only needs to be done once, even if you have multiple printers installed.


OS Version Compatibility: Leopard.


Back to the top...



Change Dock appearance


Problem: Aaaargh! I hate the transparent, 3-D, glossy Dock in Leopard! What can I do?


Solution: Issue the following command in a Terminal or xterm (X11) window:

defaults write com.apple.dock no-glass -boolean YES

Restart the Dock using the following command:

killall Dock

This will convert the Dock appearance to something similar to the Tiger version (i.e., still transparent, but 2-D with no reflections). This is the same appearance that the Dock has by default in Leopard when it is configured in the Dock System Preferences to appear on the side of the screen instead of the bottom.


Repeat with “YES” replaced by “NO” to restore the “fancy” Leopard dock appearance. The file modified by defaults in this case is ~/Library/Preferences/com.apple.dock.plist.


OS Version Compatibility: Leopard.


Back to the top...



Use Front Row without an Apple remote


Problem: Wow! Front Row is really cool! I can hardly wait to look at all of the files on my computer by flipping through a rotating display of album covers, photo thumbnails, etc. But, alas! My Mac did not come with an Apple Remote! Can I still Use Front Row?


Solution: Yes, you can. Press Cmd-Esc to start Front Row. Navigate up and down with the arrow keys, select a menu item with the Enter key, go back one menu level with the Esc key. Press Cmd-Esc again to completely exit Front Row. If Front Row freezes, press Cmd-Option-Esc.


OS Version Compatibility: Leopard.


Back to the top...



Show full directory path in Finder windows


Problem: By default in Leopard, the title in a Finder window is set to the currently viewed folder. How can I make the title be the full directory path to that folder (i.e., similar to what would be returned by the Unix pwd command)?


Solution: Issue the following command in a Terminal or xterm (X11) window:

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

Relaunch Finder (e.g., select Apple→Force Quit) to put the change into effect. Repeat with “YES” replaced by “NO” to restore the default titles. The file modified by defaults in this case is ~/Library/Preferences/com.apple.finder.plist.


OS Version Compatibility: Leopard.


Back to the top...



Stop auto-switching in Spaces


Problem: Spaces is great and all, but it forces me to sort by applications instead of tasks. For example, if I select {application} from the Dock, then it automatically switches me to the virtual desktop space in which I first started {application}. However, what I really wanted was to start another instance of {application} running in my current virtual desktop space. Assigning {application} to all desktops in the Spaces preferences isn't the solution, because then Spaces just drags around all {application} windows onto all desktop spaces.


Solution: Issue the following command in a Terminal or xterm (X11) window:

defaults write com.apple.dock workspaces-auto-swoosh -bool NO

Restart the Dock using the following command:

killall Dock

Spaces will now allow you to start multiple instances of an application in separate desktop spaces. Note that implementing this setting can result in confusing behavior if you have used the Spaces preferences to assign a specific application to a specific desktop spaces (although assigning applications to all desktop spaces appears to be fine). Repeat with “NO” replaced by “YES” to restore the default behavior. The file modified by defaults in this case is ~/Library/Preferences/com.apple.Dock.plist.


OS Version Compatibility: Leopard (10.5.2+).


Back to the top...



Disable starting an initial xterm when X11 is started


Problem: Leopard's implementation of X11 is not intended to be started from the Applications/Utilities folder (as it was in Tiger). Instead, X11 is automatically started on demand when an X application is started. X11 can still be started by itself by double-clicking on the X11 icon in the Applications/Utilities folder, but this will also automatically start an xterm. Under Leopard, there is no system xinitrc file that can be edited to disable starting that initial xterm. Please make it stop!


Solution: It's not entirely true that there is no longer a system-wide xinitrc file; it has just moved to /usr/X11/lib/X11/xinit/xinitrc.


Alternatively, issue the following command in a Terminal or xterm (X11) window:

defaults write org.x.X11 app_to_run /usr/bin/true

The true routine (intentionally) does nothing (no, really, just type man true and see for yourself). Repeat with “/usr/bin/true” replaced by “xterm” to restore the default behavior. The file modified by defaults in this case is ~/Library/Preferences/org.x.X11.plist.


(Note: Because of the new way that Leopard handles X11 compared to Tiger, you should also not configure X11 to start automatically at login, nor include it as a launcher in your Dock. Starting X11 in either of these ways will result in multiple copies of X11 running. You should also not start X11 manually - as described here - if it has already been automatically launched by Leopard.)


OS Version Compatibility: Leopard.


Back to the top...



Stop asking for confirmation before opening a downloaded file


Problem: Leopard tags files downloaded from the web, and asks for confirmation before running a downloaded application or script. While this does provide a default layer of security against running downloaded programs, it is also annoying for people who already exercise an appropriate level of caution about trusting downloaded software. (Note that this feature of Leopard does not do anything with regard to checking downloaded files for viruses, preventing malicious software from running, etc. – all it does is remind you that it was downloaded - and require an extra button-click - before the application or script can start). How can I disable this behavior?


Solution: (updated on 06/29/09) Since (approximately) Leopard 10.5.5, I have no longer noticed the really annoying aspect of this feature; namely, that it asked for confirmation every time any given application or file that was downloaded from the web was subsequently opened. Now, it seems to ask only the first time the application or file is opened, which is much more sensible and less annoying. Consequently, I have stopped trying to circumvent this behavior. The previously suggested procedure for dealing with this feature is now unnecessary to all but the most easily annoyed, and likely more effort than it is worth, but is preserved below as a historical record.


OS Version Compatibility: Leopard (10.5.5+).


THIS DESCRIPTION APPLIES ONLY TO LEOPARD VERSIONS BEFORE 10.5.5

This procedure is a little complicated, and a good explanation (with step by step instructions and screen-grabs) is available at http://henrik.nyh.se/2007/10/lift-the-leopard-download-quarantine. In the event that site becomes unavailable, I have reproduced the minimum necessary steps here.

First, save this file into your ~/Library/Scripts/Folder Action Scripts/ folder: Unquarantine.scpt. If that folder does not exist, then create it using the Terminal or xterm (X11) command:
mkdir -p ~/Library/Scripts/Folder\ Action\ Scripts
In a Finder window, navigate to (but not into) the folder that receives web downloads (e.g., this is set to ~/Downloads by default in Leopard). Right-click on the folder icon and select More→Configure Folder Actions.... Check Enable Folder Actions. If you had to create the ~/Library/Scripts/Folder Action Scripts folder, then you will also have to add it to the Folders with Actions column, by clicking on the + button next to the Show Folder button, then navigate to, and select, the ~/Library/Scripts/Folder Action Scripts folder. Finally, attach the Unquarantine action to the folder.

This folder action script runs the command:
xattr -d com.apple.quarantine "downloaded_file.zip"
The process described here will apply the Unquaratine script to only one folder. If you download files to other folders, then you will have to apply the script to those folders also for it to take effect.

Back to the top...



Why doesn't does X11 work right with Spaces?


The text shown in the box below is preserved as a historical record. The problem of Spaces losing track of which desktop a particular X11 window is located on appears to be fixed in Leopard 10.5.5, which upgraded the Apple standard X11 to 2.1.5. The odd behavior noted below regarding which preferences file is used for X11 in Leopard 10.5.4 now makes more sense as a transitional problem, since, with the update to 2.1.5, Apple's X11 appears to be conforming more to the Xquartz version, which uses the org.x.X11.plist preferences file (e.g., see the discussions of focus and click-through behavior under Leopard 10.5.5).


OS Version Compatibility: Leopard (10.5.5+).


THIS DESCRIPTION APPLIES ONLY TO LEOPARD VERSIONS BEFORE 10.5.5

Problem: When multiple X11 windows (e.g., many xterm windows) are open on different Spaces workspaces, clicking on one of the windows or putting the cursor in the window (if "focus follows mouse" is enabled for X11) does not always activate the window.

Solution: This is a known problem with the current implementation of X11 (as of this writing, OS X 10.5.4 and X11 2.1.1), which causes X11 to become confused about where windows are located when they exist on more than one Spaces workspace. The problem is that X11 treats all windows as though they exist on the same workspace; consequently, if you are trying to activate an X11 window on one workspace that is “behind” an X11 window on a different workspace, then you will actually activate the X11 window that is “in front” on the other workspace.

Starting with Leopard, Apple is using a somewhat modified version of the Xquartz open-source implementation of X11 in OS X. The Xquartz project claims to have fixed this problem as of their version 2.2; however, as of Apple's version 2.1.1 this has not yet been implemented for Leopard. See the Xquartz project web site for more information.

For now, there are two solutions to this problem, neither of which is particularly satisfying:

  1. Wait for Apple to implement the fix in a future update of Leopard or X11.

  2. Trash the Apple installation of X11 on your computer and replace it with the current version of Xquartz X11. Instructions for doing this are available from the Xquartz project web site. Note that this is not for the faint of heart. Consequences include: the OS X Software Update will no longer deliver updates to X11 (updating the Xquartz X11 requires installing updated packages from their web site), future Apple updates could disable the Xquartz X11 (requiring re-installation of the Xquartz software), names of preference files associated with X11 will change, and so on.

Odd behavior of X11 (Apple standard 2.1.1 with Leopard 10.5.4): The org.x.x11 preferences file, although ostensibly not used by Apple's standard X11 (but used by, for example, the non-standard Xquartz version of X11), appears to be created when X11 starts (if it does not exist). In addition, starting X11 with an existing version of both com.apple.x11 and org.x.x11 will sometimes use org.x.x11 as the preferences file, which usually results in your preferences (like customized items in the Applications menu), which are probably stored in the com.apple.x11 file, not being implemented. I have found that copying ~/Library/Preferences/com.apple.x11 to ~/Library/Preferences/org.x.x11 after you set up your preferences in X11 will prevent the creation of a default org.x.x11 file, and will guarantee that things like customized menu items show up regardless of which preferences file is used by X11.

Back to the top...



Time Machine is stuck on “Preparing Backup”


Problem: Normally it only takes a few minutes for Time Machine to complete its hourly backup, but now it seems like it's taking forever. I've waited N minutes before stopping it (where N > a few minutes), tried rebooting, cycling power on my Time Capsule/external backup disk, etc, but it still gets stuck on “Preparing Backup...”.


Solution: Fortunately, the solution to this problem is usually... patience. Certain events can cause Time Machine to lose track of which files it needs to backup, which necessitates performing a full comparison of your current hard drive contents to the contents of the last backup. This can cause the backup preparation stage to last for several tens of minutes to more than an hour, depending on the size of the drive you are backing up.


Events that can cause this problem include (a) the last Time Machine backup was interrupted (other than by issuing the Stop Backing Up command from the Time Machine toolbar menu), (b) your Mac was not shut down properly, (c) a mounted disk was not removed properly by ejecting it first, (d) a software update was installed (the Leopard 10.5.2 update was notorious for causing this problem), and (e) your computer was used for several days without performing a Time Machine backup (e.g., by not having the Time Machine disk connected or having backups turned off in the Time Machine preferences).


You can confirm that this is the origin of your problem with Time Machine as follows: after Time Machine starts (while it is “Preparing Backup”), open Console (from the Applications/Utilities folder) and select File→Open System Log. Near the bottom of the system log, there should be one or more time-tagged entries relating to the ongoing Time Machine process. If one of these mentions a (somewhat ominously named) “deep traversal”, then just be patient, let Time Machine do its thing, and all will be well in the future.


OS Version Compatibility: Leopard.


Back to the top...



Copy and paste between X11 and Mac OS


Problem: I often need to copy and paste text between X11 windows (e.g., xterm, gvim) and native Mac OS windows (e.g., Terminal, Firefox, Safari). This often results in undesirable results. How do I successfully (and reliably) copy and paste between these different flavors of windows?


Solution: Follow the instructions below to copy from one flavor of window and paste into another. Note that gvim and other X11 windows behave differently, but all Mac OS windows behave like Terminal. Some of these instructions require that you have click-through enabled in X11 and all of them assume that you are using a three-button mouse or the corresponding keyboard equivalents for a single-button mouse. The latter, in turn, requires that in the Input panel of the X11.app preferences, you have selected “Emulate three button mouse” and “Enable key equivalents under X11”.



Note added on 06/29/09: I've recently been helping someone who had just upgraded from Tiger to Leopard, and found that no matter what she did, Cmd-C in a Mac OS window would not paste into an X11 window. After a lot of experimenting, here is how I resolved her problem:


Method 1:

  1. First, read all the way to the bottom of this configuration tip before you start this procedure, since there might be a better (or at least different) way to do it that will work for you...

  2. Quit X11.app if it is running (Cmd-Q or select X11→Quit X11).

  3. Open a Finder window and navigate to ~/Library/Preferences/. This is not the system-wide /Library folder, but the one in your user account home folder.

  4. Double-click on org.x.X11.plist, which will open this X11 preferences file in the Property List Editor application.

  5. You should see one line in the editor window that says
    Root     Dictionary     22 key/value pairs
  6. Click on the small triangle to the left of the word Root to toggle open the parameter listing. Parameter values (in the Values column) can be changed by clicking on the corresponding up/down arrow icon on the right side of the Values column, then selecting from the available values in the resultant pop-up menu.

  7. Ensure that all of the following parameters have values of “Yes”:
    sync_clipboard_to_pasteboard
    sync_pasteboard
    sync_pasteboard_to_clipboard
    sync_pasteboard_to_primary
    sync_primary_on_select
    wm_click_through
    wm_ffm
    The last two of these enable click-through and enable focus-follows-mouse in X11, respectively; the others enable synchronization between the various buffers that are used to store copied text.

    Note added on 07/27/09: The advice to set all of the parameters listed above to “Yes” is a brute force approach; I have not tested all possible parameter settings, so it is possible that not all of these parameters are required to produce the desired copy/paste behavior, and some parameters may have unintended (and possibly undesired) consequences for other programs. For example, M. Parry has informed me that after following the procedure described here, he started to get the following error when using LyX:
    QClipboard::setData: Cannot set X11 selection owner for CLIPBOARD
    and had severely reduced cut and paste functionality within Lyx itself. Setting sync_clipboard_to_pasteboard back to “No” resolved the problem with LyX and still preserved the desired copy/paste behavior between X11 and OS X windows.

  8. Save the modified preferences file (Cmd-S or select File→Save).

  9. Quit the Property List Editor (Cmd-Q or select File→Quit Property List Editor).

  10. The next time X11 is started (e.g., by typing xterm on a Terminal.app window command line), the copy/paste behavior should conform to the descriptions listed above.

Update added on 09/09/09: A few people who have tried the procedure listed above (henceforth, “Method 1”) have reported to me that it did not work for them. I do not know for certain why, but I suspect it might have to do with what original version of X11 was installed on your computer and subsequently updated via Software Update, vs. starting fresh with a more recent version of X11 (e.g., if you have recently purchased a new Mac, or installed Leopard at a starting version of, say 10.5.5+) – see below for more information about this issue.


In any case, here is an alternate procedure (henceforth, “Method 2”), which seems to work if the above procedure does not. In fact, Method 2 is even better than Method 1, in the sense that it implements permanent easy access to the X11 copy/paste parameters without having to use the Property List Editor. Method 2 can even be applied on top of Method 1 with no apparent ill effects.


Method 2:

  1. Start X11 (e.g., by typing "xterm" in an Apple Terminal window (remember, under Leopard, you should avoid starting X11 directly yourself, since it is started “on demand” by the OS).

  2. Pull up Preferences under the X11 menu.

    • If you have 5 tabs (Input, Output, Pasteboard, Windows, Security), then you are already set - go to the Pasteboard tab and click all of the boxes on. (As noted in Step 7 of Method 1, some experimentation regarding which of these boxes actually need to be clicked to obtain the desired copy/paste functionality may be required if you find that having all of them on interferes with the operation of a particular software title.)

      Update added on 10/07/09: After using X11 for a while now with the new preferences panels, I have found that deselecting the final option on the Pasteboard tab, “Update Pasteboard immediately...”, produces more reliable copy/paste results between OS X application windows and, for example, an X11 vim window. I have updated the screen grabs shown below to reflect this.

    • If you only have 3 tabs (Input, Output, Security), then quit X11 and continue to the next step...

  3. Install the X11 localization preferences for Xquartz 2.3.3.2, which I have made available here:

    X11-Locales-2.3.3.2.dmg.

    Even if you are running the Apple standard X11 (which, as of OS X 10.5.8, is based on Xquartz 2.1.6), this will activate two new panels in your X11 preferences.

    Note that I do not know of any way to UNDO this (short of reinstalling OS X), so use at your own risk!

  4. Start over from Step 1 of Method 2...

To help illustrate Method 2, I have provided screen grabs of my X11 preferences settings after installing the X11 localization.


Update added on 09/23/09: The XQuartz project web site has this to say about the X11 localization fix described here (thanks to P. Chakka for notifying me about this):

“[OS X version] 10.5.7 updates the X11 server to match what shipped with [XQuartz X11 version] 2.3.2. Most of the userland, however, only saw security updates. The version reported by X11 in 10.5.7 is 2.1.6 to distinguish it from the 2.3.x series which contains a much newer userland. Users have reported some issues with the updated X11 in 10.5.7:

... Clipboard doesn't work after editing preferences → Install the localization updates that contain the clipboard preferences.”


Although XQuartz recommends installing the latest full XQuartz version of X11 to fix this problem (as they always recommend), I note (as described above in Method 2) that simply installing the localizations with Apple's X11 v2.1.6 activates the “missing” preferences panes, and fixes the copy/paste problem (or at least provides easy access to the associated preferences). In the past, I have generally recommended against installing the XQuartz X11 for most users, because it then requires manual reinstallation whenever Apple pushes out updates to their version of X11 through Software Update. However, with Leopard now presumably finalized, this is no longer an issue (barring unexpected future updates to the Leopard X11 from Apple).


OS Version Compatibility: Tiger (untested but Method 1 might work); Leopard.


Back to the top...



Create and use an encrypted disk image


Problem: I have secrets. How can I safely store them on a computer disk or on a USB flashdrive?


Solution: In Mac OS X, you can create an encrypted, password-protected disk image (i.e., a .dmg file). This disk image can be opened and mounted (provided you know the password) to access the files stored within. After mounting, existing files can be opened and/or removed from the disk image, and/or new files can be added to it (up to the pre-set size limit of the disk image). The disk image can then be unmounted and will return to its encrypted, password-protected state. Disk images can be stored on your computer's disks or copied to a USB flashdrive or other external storage medium. This encrypted disk image will only work on Mac OS X systems.


Creating an Encrypted Disk Image:

  1. Start Disk Utility (located in /Applications/Utilities/).
  2. Select File→New→Blank Disk Image to pull up the New Blank Image dialog box.
  3. Enter a name for the .dmg file in the Save As field.
  4. Select the save destination.
  5. Enter a name in the Volume Name field. This is the name that will be assigned to the opened disk image once it is mounted (i.e., the name that will show up in /Volumes). This can be the same or different from the name of the .dmg file. The default value is “Disk Image”.
  6. Select a size for the disk image file from the Volume Size menu. The disk image will take up this amount of disk space no matter how many files are actually stored in it, but you do not need to fill up the disk image. You also cannot exceed the volume size when adding files to the disk image. (“Sparse disk images”, which increase in size up to a pre-set limit as files are added to them, are not covered in detail here. Note, however, that while a sparse disk image will increase in size up to its pre-set limit as new files are added to it, it will not decrease in size when files are removed from it.)
  7. Choose a volume format; “Mac OS X Extended (Journaled)” is recommended.
  8. Choose “128-bit AES”(Mac OS X 10.4 or later) or “256-bit AES” (Mac OS X 10.5 or later) from the Encryption menu. 256-bit encryption offers the highest level of security.
  9. Select “Single partition - Apple Partition Map” from the Partitions menu.
  10. Choose an image format; “read/write disk image” is recommended, but you can choose “sparse disk image” if desired (see above).
  11. Click the Create button.
  12. The password entry dialog window will appear. Enter and verify a good password. By default, this password will be saved in your keychain, or you can deselect “Remember password (add to keychain)” (I recommend the latter for highest security; note, however, that if you cannot remember your password in the future, then there is no way to open the encrypted disk image).
  13. Click “OK” in the password entry dialog window.

Using an Encrypted Disk Image:

  1. When you initially create an encrypted disk image, it will be open and mounted, ready for use. To open a previously created encrypted disk image, double-click on it in a Finder window and enter the password when prompted.
  2. Double-click on the disk image icon on the Desktop, or click on its small icon in the Devices pane of a Finder window. This will open a Finder window showing the contents (if any) of the disk image.
  3. Open, add, and/or remove files as desired.
  4. When finished, drag the disk image icon on the Desktop to the Trash (which will switch to the Eject icon) or click on the eject icon next to the disk image in the Devices pane of a Finder window. This will close and unmount the encrypted disk image - your secrets are safely hidden again.

OS Version Compatibility: Tiger and Leopard (with slightly different procedures).


Back to the top...



List the OS version from the command line


Problem: I know that I can find my current OS version number by selecting About This Mac under the Apple menu, but is there a way to get that information from the command line (e.g., if I am logged in to a remote machine and don't have access to the Desktop menus)?


Solution: Use the command sw_vers. For example,

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.5.8
BuildVersion:   9L30

The following command gives just the version number:

sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'

OS Version Compatibility: Tiger and Leopard.


Back to the top...




Turn Time Machine off/on using cron


Problem: Let's say, just for fun, I wanted to be able to turn Time Machine off and on at specific times during the day (e.g., if I only want Time Machine to run at night). How can I do that?


Solution: It's cron to the rescue...

  1. Create two bash scripts that will edit the Time Machine preferences file to turn Time Machine on or off. This is accomplished using the command

    defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -boolean YES

    to turn Time Machine on or

    defaults write /Library/Preferences/com.apple.TimeMachine AutoBackup -boolean NO

    to turn Time Machine off. You can also just download my scripts: TMon.sh and TMoff.sh

  2. Create a hidden directory in your home directory in which to store the scripts, using the following command in a Terminal or xterm window:

    mkdir ~/.cron.daily

    and move the scripts into it. For example, if the scripts are currently in your Downloads folder, then use the command:

    mv ~/Downloads/TM*.sh ~/.cron.daily

  3. Create a .crontab file in your home directory. See “Use cron to schedule automatic tasks” for more information about setting up and using cron. Basically you will want your .crontab file to look like this:

    # minute hour mday month wday command
    00 08 * * 1-5 /Users/yourname/.cron.daily/TMoff.sh
    00 17 * * 1-5 /Users/yourname/.cron.daily/TMon.sh


    Change yourname to your short user (login) name. This would turn Time Machine off at 8am, and then back on at 5pm, on Monday through Friday. Since Time Machine is turned on at 5pm on Friday, it will run through the weekend and then turn off again at 8am on Monday. If you want Time Machine to turn off/on on every day of the week, then replace 1-5 with *.

  4. Don't forget to start cron after setting this up, using the command

    crontab /Users/yourname/.crontab

  5. A few caveats:

    (a) If you are already using cron for other tasks, then the Time Machine control scripts can be added to your existing .crontab file. Don't forget to stop cron before editing the file, then restart it afterward – see “Use cron to schedule automatic tasks”.

    (b) cron will not run if the computer is asleep, so keep that in mind if using this procedure on a laptop or other computer that is configured to sleep when not in use.

    (c) Time Machine will not make backups while it is turned off. Are you certain that you want to do this?

OS Version Compatibility: Leopard.


Back to the top...




Mac OS X Configuration Tips
by
Back to D. W. Hoard's Home Page