Open 0xdevalias opened 4 years ago
The following is an extract from my (private) obsidian note: DeepDive - Dotfiles (and macOS defaults, settings) management tools, processes, etc
obsidian://open?vault=Notes%20(Dropbox)&file=deepdive%2FDeepDive%20-%20Dotfiles%20(and%20macOS%20defaults%2C%20settings)%20management%20tools%2C%20processes%2C%20etc)
Automate macOS launchpad sorting, folders, etc
It would be cool if we could create folders and sort apps into them in an automated way
How macOS Stores Launchpad Configuration
Connecting to the Launchpad SQLite Database
cd $(getconf DARWIN_USER_DIR)/com.apple.dock.launchpad/db
sqlite3 --column --header db
.schema
For anyone who stumbles across this article and is interested in the YAML-based script for configuring things, the (archived) repo appears to be available here: https://github.com/fgimian/launchpad.cr
There's also a Python version here if you prefer: https://github.com/fgimian/macbuild-ansible/blob/master/extras/launchpad.py
The Launchpad database is located at
~/Library/Application Support/Dock/*some-hex-name*.db
. To edit it, you'll have to use SQLite.
On [[macOS]] Sierra and newer the old launchpad database does not exists anymore. Instead every user has his personal launchpad database somewhere inside
/private/var/folders
The
/private/var/folders
directory contains lots of cryptic folder names, but you can identify the path to your user's personal folder usinggetconf DARWIN_USER_DIR
. You may note this command returns a path inside/var/folders
instead of/private/var/folders
, but/var
is a symlink to/private/var
.
echo /private$(getconf DARWIN_USER_DIR)com.apple.dock.launchpad/db/db
the value for some-hex-name is stored in
~/Library/Preferences/ByHost/com.apple.dock.*another-hex-name*.plist
asLaunchPadDBName
.
defaults -currentHost read com.apple.dock LaunchPadDBName
defaults -currentHost write com.apple.dock ResetLaunchPad -bool true; killall Dock
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
How to organize and clean up Launchpad on the Apple Mac
Change the Launchpad layout
defaults write com.apple.dock springboard-rows -int N
defaults write com.apple.dock springboard-columns -int N
Replace the N at the end to set the number of rows and columns of icons to display, such as 3, 5, 6, whatever. You need to restart the Mac after entering those Terminal commands.
How do you reset Launchpad?
defaults write com.apple.dock ResetLaunchPad -bool TRUE && killall Dock
Launchpad database location
If you don’t want to use terminal commands you can use an app called Launchpad Manager to do all of the work for you. Launchpad Manager will present you with a view of your Launchpad screen and allow you to add, delete, arrange, or group any of your icons.
How to use Launchpad on your Mac like a pro
defaults write com.apple.dock springboard-columns -int 4
defaults write com.apple.dock springboard-rows -int 6
defaults write com.apple.dock ResetLaunchPad -bool TRUE
killall Dock
ChatGPT Ref: https://chat.openai.com/chat/68754471-c6a5-446e-a37b-af15d36c72c6
USER
What is the macOS screen called that shows all installed apps?
ASSISTANT
The macOS screen that shows all installed apps is called the Launchpad. It provides a convenient way to access and launch applications on a Mac, similar to the home screen on an iOS device. The Launchpad can be opened by clicking on its icon in the Dock, pressing the F4 key on newer Macs, or using a multi-touch gesture. Once open, you can scroll through your installed applications, organize them into folders, or search for a specific app using the search bar at the top.
USER
Where is the data from launchpad stored, including the folder names, and which apps are stored within them?
ASSISTANT
The data for Launchpad is stored in a database file called "db" located in the folder
/private/var/folders/xx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/0/com.apple.dock.launchpad/
. Thexx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
part of the path is a randomly generated folder name that will be different on every Mac. You can navigate to this folder by opening Finder and pressingShift+Command+G
, then pasting the above path into the "Go to folder" dialog.Within this folder, you will find the Launchpad database file named "db". This file contains information about all of the apps installed on your Mac, including their names, icons, and the folders they are organized into. It is a SQLite database file that can be opened and queried using various third-party tools.
Note that modifying this database file directly can be risky and may cause issues with Launchpad. It is recommended that you use the built-in functionality of Launchpad to organize your apps, rather than attempting to modify the database file manually.
USER
How can I directly access the database?
ASSISTANT
Directly accessing and modifying the Launchpad database file can be risky and may cause issues with Launchpad. However, if you still want to access the Launchpad database file, you can use a SQLite database viewer, such as the free "DB Browser for SQLite" application.
Here are the steps to access the Launchpad database file:
Download and install DB Browser for SQLite from its official website.
Open the "Finder" application on your Mac, then press "Shift+Command+G" to open the "Go to Folder" dialog.
In the "Go to Folder" dialog, type
/private/var/folders
, then press the "Go" button.In the "folders" folder, you will find a randomly named folder. Open it and navigate to
/0/com.apple.dock.launchpad/
.In this folder, you will find the Launchpad database file named "db". Make a backup of this file before you proceed.
Open the DB Browser for SQLite application, and select "Open Database" from the "File" menu.
In the file selection dialog, navigate to the Launchpad database file named "db", select it, and click the "Open" button.
You can now view and query the Launchpad database using DB Browser for SQLite.
Note that modifying the Launchpad database file directly can be risky and may cause issues with Launchpad. It is recommended that you use the built-in functionality of Launchpad to organize your apps, rather than attempting to modify the database file manually.
USER
What tables exist in this db, and what are they used for?
ASSISTANT
The Launchpad database file ("db") contains several tables that store information about the installed applications and how they are organized within Launchpad. Here is a brief overview of the tables and their purpose:
apps: This table contains information about each installed application, such as its name, bundle identifier, and path to its executable file.
groups: This table contains information about each Launchpad folder, such as its name and position within Launchpad.
items: This table contains information about each item in Launchpad, which can be an application or a folder. This includes the item's position within Launchpad, its type (app or folder), and its association with a specific app or folder.
aliases: This table contains information about any aliases used in Launchpad, which can point to an application or a folder.
bundle_data: This table contains additional information about each installed application, such as its icon and version number.
dbinfo: This table contains metadata about the Launchpad database, such as its schema version and last modified date.
pictures: This table contains information about the pictures used in Launchpad, such as their name and file path.
These tables are used by Launchpad to organize and display the installed applications on your Mac. By querying and modifying the Launchpad database file, you can change how the applications are organized and displayed within Launchpad. However, modifying the Launchpad database file directly can be risky and may cause issues with Launchpad. It is recommended that you use the built-in functionality of Launchpad to organize your apps, rather than attempting to modify the database file manually.
It would be cool if we could create folders and sort apps into them in an automated way.
defaults -currentHost read com.apple.dock LaunchPadDBName
lsof | grep myfilename