Add folder to favorites and change folder icon [El

2019-07-19 03:19发布

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:

2条回答
家丑人穷心不美
2楼-- · 2019-07-19 03:37

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 the fileicon 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

查看更多
女痞
3楼-- · 2019-07-19 03:55

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

查看更多
登录 后发表回答