Programmatic way to save and re-create launchpad groups in Mojave

backupcommand linelaunchpadmojave

I have to switch machines from time to time. I keep a dotfiles that's pretty elaborate, as part of this routine. I'd also like to make my launchpad folders be portable.

I'm fine with solution that involve the CLI, applescript, or anything that I can do reliably.

A commentor indicated I can run find /private/var/folders -type d -name 'com.apple.dock.launchpad' 2>/dev/null

but it yields multiple results:

/private/var/folders/sy/wnh38ggx3111qkdkjy2gvk940000gn/0/com.apple.dock.launchpad
/private/var/folders/xq/ynvgvft97l9_rx42cvywqx2m0000gp/0/com.apple.dock.launchpad
/private/var/folders/th/gjmmnngn4l13w0_xyxhr4y6c0000gq/0/com.apple.dock.launchpad

A similar question was asked, but that was a while ago. In an apple forum, someone shared the location of the core / default Dock DB, but not the user-specific one.

If anyone knows how these strings are generated, it might be a viable answer.

Best Answer

In true form, along the way of figuring out how to ask the questions, I seem to have found part of a hint.

There is a folder path /private/var/folders/ that contains a rats-nest of directories with non-human-parseable names. Supposedly one of these contains my Launchpad's database.

If I can learn which, and how to find it programmatically, I will update the answer


The DB groups name + parents can be found in the DB with via

SELECT * 
FROM items i JOIN groups g ON g.item_id = i.rowid 
ORDER BY i.parent_id, i.ordering

The issue remains that apps are listed by a UUID, not name. This suggests that they may not port well to a different computer, since a UUID is typically made in the local context. However, apps registered via the app store or via Apple's dev program may have consistent UUIDs.