Backing up the Launchpad Database on your Mac

I recently achieved a goal I had made for myself quite some time ago. I organized my Launchpad database. Launchpad provides a relatively simple way to launch apps on your Mac, especially if you have so many apps that you can’t always remember their names. If you can remember the name or even a part of a name for an app you want to launch, you can activate launchpad from the Dock (It appears there by default) and start typing. If you don’t remember even part of its name, you can organize the Launchpad layout by dragging app icons onto each other, then by dragging the icons into the folders that have already been created by dragging app icons onto each other. You can rename the folders by activating a folder then clicking the name displayed above the icons. That way you can organize the layout in such a way that you can browse the folder that might contain the app you want to launch. In other words you can organize by category to search for an app by icon and/or name. Recursive folders aren’t allowed though.

Here’s a summary of how to use Launchpad. It can be triggered (as I already mentioned) by clicking its icon in the Dock, or by using a keyboard shortcut or a trackpad gesture configured in System Settings. To configure the Keyboard shortcut, select Keyboard in System Settings, then press the Keyboard Shortcuts button and choose the option for Show Launchpad, customizing the shortcut to your preference (mine is ⇧⌃⌥L). To configure a trackpad gesture that will activate Launchpad, select Trackpad in System Settings, then click More Gestures and enable the Launchpad item (the gesture is “Pinch with thumb and three fingers”). Once Launchpad is activated, any apps contained in Launchpad whose names contain the letters that you type will then appear in the Launchpad window. When you see the app you want to launch, navigate to it using the arrow keys then press enter, or just click its icon. You can exit Launchpad by clicking anywhere there isn’t an icon. Pressing the escape key (esc) while Launchpad is active (or clicking anywhere there isn’t an icon) will cause Launchpad to return to its previous state. For example, If you just entered Launchpad, then escape simply deactivates or exits. If you have either typed something to filter the app icons displayed in Launchpad or filtered the icons by clicking a folder in the Launchpad window, escape takes you back to the main Launchpad window at which point pressing escape again exits Launchpad.

Having organized the arrangement for apps that can be launched using Launchpad, it occurred to me that backing up that database might prevent me from losing all the work I had put into creating the layout. The following AppleScript allows me to access and make backups for the database that controls the Launchpad layout. I can restore that configuration to a different user or I can restore to the same user from which the files were originally copied in case I make changes to the state of the Launchpad configuration that I decide not to keep. Additionally, It provides a lateral means of access to the user’s folder of private settings and the information stored there.

Backing up the files that contain the Launchpad configuration for the current user is simple. Just copy the three files contained in the folder opened by the following AppleScript to a location where you want to keep the backup. Because of persistent caches, restoring the Launchpad configuration requires that the group of three active files must be moved to a different location (such as the trash) so that the files to be restored can then be moved into the active Launchpad database folder in their place. After the files have been restored in this way, it should be safe to activate Launchpad to be sure the correct configuration exists. If it does, then the previously active files can safely be deleted. If the wrong Launchpad configuration still exists, then go ahead and delete the files that were already discarded by putting them in the trash and emptying it. Then simply repeat the operation, but rather than immediately activating Launchpad after the restored files have been put into the active Launchpad database folder, restart the Mac first.

--begin AppleScript--
set i to POSIX file (do shell script "echo $TMPDIR")
tell application "Finder"
	set f to get container of folder i as alias as string
	reveal f & "0:com.apple.dock.launchpad:db:db"
activate
end tell
--end AppleScript--

You might also be interested in another post I created called Launchpad Lightener. Launchpad Lightener is an AppleScript I wrote that allows you to remove items from Launchpad that might be difficult to remove any other way. It lets you remove the icon from Launchpad without affecting the original item in any other way.

One thought on “Backing up the Launchpad Database on your Mac

Leave a comment