Adding an item to the sidebar of the Finder / Save dialog box

I am working on a script when a user logs into a guest OS account and asks for their network credentials in order to mount their home home folder (although they can work in the user's local folder).

When the guest folder is deleted, when users log out, I want to dissuade them from saving anything there. I would like to replace the items in the Finder and Open / Save sidebar lists (for example, "Desktop", username, "Documents", etc.) with those that will be saved in the network home folder.

Can this be done using the AppleScript or Cocoa API, or do I need to change the plist and restart the Finder? [Ack. Looking at ~ / Library / Preferences / com.apple.sidebars.plist, it’s not at all clear how I populate it.]

Related questions:

AppleScript: adding an attached folder to the sidebar Finder?

  • suggests using fstab; this code is likely to work as a user, and indeed, automation at this point will be too late.

How do you programmatically place folder icons in the Finder sidebar, considering you need to use a custom icon for this folder?

  • Says there is no Cocoa API, but you can use the LSSharedFileList API with a carbon interface that is documented in only one header file.
  • Does anyone know sample code to add an item to the sidebar Finder?
+1
cocoa applescript finder macos sidebar
source share
2 answers

Can this be done using the AppleScript or Cocoa APIs, or do I need to change the plist and restart the Finder?

Not.

As I said on this other issue, the correct way to add an item to the sidebar is to use the LSSharedFileList.

+3
source share

An employee came up with this method that uses applescript:

tell application "Finder" activate -- Select the path you want on the sidebar in the Finder select folder "Preferences" of folder "Library" of (path to home folder) tell application "System Events" -- Command-T adds the Documents Folder to the sidebar keystroke "t" using command down end tell end tell 
+3
source share

All Articles