Fixing a Mac OSX Leopard Login Loop Caused by Launch Services

After the release of the latest update to the Macintosh operating system (10.5.3), some users were reporting a “login loop” to I followed the always helpful advice on MacFixIt for updating the operating system, and after the first reboot everything came back fine on my PowerBook G4 I thought I was in the clear. With the second reboot, though, I started seeing the login loop: the machine boots fine, but when you put the username and password in, the system hangs for about 20 seconds before displaying the login window again. Clearly something is hosed, and fortunately I was able to fix it.

I tried the suggested solutions — booting in safe mode and logging in (still had the same problem); running a file system check in single user mode (no errors reported); deleting the login window plists; and changing the password — but they had no effect. I could log into the temporary admin account I give to Apple when the machine is sent in for service, so I knew it was something specific to my day-to-day account. I was able to get into single user mode (hold down Command-S right after the startup twang) and examine the /var/log/system.log file. This is part of the underlying UNIX nature of MacOSX, and was the only place I found that gave clues to what was going on. Here is a portion of the log file that occurs right after hitting return at the login screen:

loginwindow[23]: USER_PROCESS: 23 console[1] ([86]): Exited: Terminated
ReportCrash[106]: Formulating crash report for process lsregister[104]
ReportCrash[106]: Saved crashreport to /Library/Logs/CrashReporter/lsregister_timestamp.crash using uid: 0 gid: 0, euid: 0 egid: 0
kernel[0]: SetCryptoKey R: len 32, idx 1
ReportCrash[111]: Formulating crash report for process ReportCrash[105]
ReportCrash[111]: Saved crashreport to /Users/userid/Library/Logs/CrashReporter/ReportCrash_timestamp.crash using uid: uid gid: gid, euid: uid egid: gid[92] ([105]): Exited abnormally: Bus error
ReportCrash[112]: Too many crashes in rapid succession! No crash report being written for pid 113[1] ([113]): Exited abnormally: Segmentation fault[1] ( Throttling respawn: Will start in 10 seconds
ReportCrash[112]: Too many crashes in rapid succession! No crash report being written for pid 114

The key clue is bolded — the lsregister process is crashing. I found a clue to the fix in a 2003 blog posting by a guy named Rick when he said After a couple hours of snooping, and some luck (I was able to ssh in from another machine and watch the system log report the crashes), I discovered that Launch Services’ cache was corrupted, and was causing lsregister to seg fault. His posting was related to MacOSX 10.2.6, and since then the name of the Launch Services cache file has morphed. I found it in the same place (the /Library/Caches directory), but now there is more than one and they take the form of “” where uid varies depending on the appropriate userid number. I removed all of the Launch Services files from /Library/Caches, restarted, and was able to log in fine. The only side effect was that the applications-to-launch-at-login list was gone (the “Login Items” tab of the Account Preference Pane) and had to be reconstructed.

So I’m productive again, and I didn’t have to reinstall the operating system or transfer all my old files and settings to a newly-generated account. I hope this message helps someone else, too.

Getting a Hyperlink of the Last Sent Message from using Applescript

I’ve been a fan of Getting Things Done as a technique for managing projects, but it was only recently that I settled on OmniFocus as the “trusted system” collecting all of my next actions. One of the things I like about OmniFocus — as a rich, Mac-only application — is its ability to hold links to messages from as notes for each action. This occurs, for instance, when you use the “Clippings” function of OmniFocus to create a new action based on the message that you are currently viewing in (There are other ways to do it, such as the method described by Adam Sneller.)

One of the things I find myself doing is creating actions in a “Waiting” context based on e-mail messages I’ve just sent. Initially, I’d just create the action via the OmniFocus Quick Entry window. But I found myself needing to refer back to the message I sent when the person I’m waiting on doesn’t come through. So I started clicking and dragging the message from the Sent mailbox to the action. But to do that I’d have to click into the Sent mailbox and have the and the OmniFocus windows set up just right. Or I’d have to follow a select-sent-mailbox, select-message, OmniFocus-quick-entry-with-clipping, select-Inbox, select-next-message workflow. And that took time and effort. So I’ve created an AppleScript ditty that does the work of creating a hyperlink on the clipboard of the last sent message. The results can then be pasted into any RTF-aware application, including OmniFocus.
Continue reading

PocketModMac: MacOSX PocketMod Generator Via Print Dialog

This one goes out to all of the MacOS X users out there. (For the rest of you, why aren’t you switching?) Perhaps you have seen PocketMod — the origami-like manipulation of an 8 1/2″ by 11″ piece of paper into an 8-page booklet.

PocketMod example pictureExample PocketMod, courtesy of the Boston Globe.

Touted as a way to “get back to the basics” using analog media over digital media, it is a scheme by which you can transform pages of text into a pocket-sized form for carrying around. Many use it as a way to synchronize their digital to-do lists with the analog world, while others use it document shortcuts and cheat-sheets in a convenient form.

I’m migrating from Thinking Rock to iGTD as my Getting Things Done tool-of-choice. One of the things I’m missing about Thinking Rock is its built-in ability to create PocketMods for the actions in the GTD system. The only real easy way to create the PocketMod format was via a Flash applet or a Windows application. Some have set up shell scripts or worked with other programs, but I was looking for something as simple as the MacOS X print dialog box. And with a little bit of Automator, Java, and shell scripting, it is possible!

Step 1: Get the “Multivalent” PDF Manipulation Toolkit

The heavy lifting of this solution uses the Multivalent PDF Manipulation Toolkit. This is a Java-based application that perform various actions (impose, compress, uncompress, info, encrypt / decrypt, split and merge, and validate) on PDF documents (as well as other file formats). It is an open source application available under the GPL license (although some components of Multivalent have commercial use restrictions) available from SourceForge at this download URL: Multivalent20060102.jar. Download that file and save it somewhere on your hard drive. You’ll need to know the direct path location for the next step.

Step 2: Create the Automator Action

Launch “Automator” (you’ll find it in the Applications folder). It will start with a new, untitled work document. From the left-most panel, select “Automator”, then from the panel just to the right of that click and drag “Run Shell Script” to the empty document on the right.
Dragging "Run " to empty windows

In the ‘Run Shell Script’ action, change “Pass input” to “as arguments” then replace “cat” in the command box with this (ignoring any line breaks that may appear here — this text should be entered without line breaks):

cat "$1" > /tmp/temp$$.pdf && java -classpath [location]/Multivalent20060102.jar tool.pdf.Impose -dim 2x4 -layout "1l,2r,8l,3r,7l,4r,6l,5r" -paper letter -verbose /tmp/temp$$.pdf 2> /tmp/temp$$.err && open /tmp/temp$$-up.pdf

Replace [location] with the complete file path where you downloaded the Multivalent20060102.jar file. The final results should look something like this:
Completed action

Now save this as “PocketModMac” in either the “/Library/PDF Services” directory (to make it available to all users of your machine) or to “Library/PDF Services” in your home directory for just you.

Step 3: Using PocketModMac

Using this PocketMod generator is as simple as printing any document to any printer. In the print dialog box, pull down the PDF menu and select “PocketModMac”.
Print Dialog

After a few seconds, the Preview application will open up with the PocketMod-ed document. Print this document as you would to any printer, then follow the directions for folding and cutting the page to create your booklet.
Folding Instructions

Troubleshooting and Known Issues

Using Automator to string together a Unix command line like this is moderately fragile and doesn’t provide for a lot of feedback on potential errors. If it doesn’t work for you, one place to look for problems is in the /private/tmp directory for a file called temp[number].err. The contents of that file may give clues as to what went wrong.

This isn’t necessarily a very nice solution because it leaves files laying around in the /private/tmp directory after it is done. The /etc/periodic/daily/500.daily maintenance script will clean them out automatically after three days, but still — it is somewhat sloppy to leave them around.

The text was modified to update a link from to on December 4th, 2012.

The text was modified to update a link from to on December 4th, 2012.

The text was modified to update a link from to on December 4th, 2012.