Since one week I'm looking for a solution to add a folder with a specific icon to the favorites sidebar (like Dropbox does it)
Is there any solution to do this with Electron or Objective C?
What I've found so far:
- drag & drop it by yourself
- fileicon
- Programmatically add a folder to "Places" in Finder (don't know if I can extend electron)
Ok I've found this solution:
On macOS you can find this Folder
~/Library/Application Support/com.apple.sharedfilelist/
It contents some *.sfl files. You can edit them with this tool/usr/bin/sfltool
. (It's installed on your mac >= 10.11 El Capitan automatically)Example to add a folder to your favorites:
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///YOURPATH
I can run this command via
require('child_process').exec
in my electron app and add a folder icon with thefileicon
module. (https://www.npmjs.com/package/fileicon)This is a little bit dirty, but I don't know an other solution.
[UPDATE]: Read first comment
You can edit the sidebar on Mac using the
com.apple.sidebarlists.plist
preference file. The items will be in the favoriteitems dictionary.The items you see are all set to being AlwaysVisible. You need to edit that file to add your own file.
I will give some links that might help you.
About the com.apple.sidebarlists.plist file, http://www.thexlab.com/faqs/finder.html
Finding the com.apple.finder.plist, https://discussions.apple.com/thread/4122582
Another post, https://apple.stackexchange.com/questions/139305/how-can-i-add-new-folders-to-the-favorites-in-the-finder-sidebar