I want to pin an item (an app or a .webloc file) in the MacOS dock. Has apple provided an API for this?
I have seen in other forums that it could be done using the following command.
defaults write com.apple.dock persistent-others -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" **file/location** "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
This command adds the item in the com.apple.dock.plist file, which stores all the items present in the dock. This file is present in ~/Library/Preferences/
.
But the dock needs to be killed once first for the item to show as pinned in it after running the command . Killing the dock can have undesirable effects, for example it maximises the minimised apps and files. Is there any way to pin the item without killing the dock?