com.apple.sidebarlists in El Capitan

plawrence
Contributor II

Hi all

Has anyone had any luck configuring the com.apple.sidebarlists plist in El Capitan? In previous versions of OS X I would drop a pre-configured plist in the User Template folder. That appears to be working for other plists (such as the dock) even with the SIP changes in 10.11, but the com.apple.sidebarlists file doesn't want a bar of my changes.

30 REPLIES 30

jford01
New Contributor

Hi there,
have you tried converting said plist to a .mobileconfig file with Tim Sutton's mcxToProfile? https://github.com/timsutton/mcxToProfile
This python script will convert your com.apple.sidebarplists into a .mobileconfig which you would then be able to upload to your jss or other mdm solution.

I have used this to manage custom sidebars and other similar prefs in Yosemite with success for the past year in an effort to discontinue using the user template folder for user template customisations, as Apple for the past few years has been encouraging us to move away from modifying the UserTemplate Folder and instead use config profiles and/or scripts to achieve similar outcomes.
As I have not began testing El-Cap in my environment yet, I am unable to say weather this method will resolve your sidebar issue in El-Cap, but could be worth a go.

Hope this points you in the right direction,
Jordan

plawrence
Contributor II

I've been looking into other options to try and configure the sidebar favourites in El Capitan. I tried converting a plist into a Configuration Profile, but that didn't work either (I also want my users to be able to modify the sidebar afterwards).

I've tried https://github.com/matt4836/changeSidebarLists and http://errorfreeit.com.au/blog/2015/5/22/deploy-finders-sidebar-list-favorites but the python script appears to have some LSSharedFileList library issues in 10.11.

I then discovered https://github.com/Aeon/sidebarFinagler which is built for 10.11 and can export and import a set of favourites. This appears to work, but as it doesn't allow for the ~ character in the path of the favourite, it isn't the clean solution I was after.

I think I've also found out why my .plist solutions haven't been working, 10.11 appears to now store the sidebar favourites in ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.FavoriteItems.sfl. I cant see an easy way to manage/configure this file.

If anyone has an elegant solution for adding the users Home folder to the sidebar in 10.11, I'm all ears! I'd prefer to be able to set something up in the user template, rather than a login script though.

bpavlov
Honored Contributor

Have you considered just setting new finder windows to open up in the user's home directory instead?

/usr/bin/defaults write "$USER_TEMPLATE"/Library/Preferences/com.apple.finder NewWindowTarget -string PfHm

Where $USER_TEMPLATE would be the /System/Library/User Template/<folder>

plawrence
Contributor II
Have you considered just setting new finder windows to open up in the user's home directory instead?

Yeah, thats my current workaround. I don't like that this doesn't put the home directory in the sidebar though :(

morgrowe
New Contributor II

I use "mysides" (https://github.com/mosen/mysides) on OS X Yosemite to add the user's network home folder to the sidebar at login. I don't see why the same can't be done for the user's local home directory.

It seems to work fine on El Cap too.

Sanchi
Contributor

@morgrowe How do you use this? I'm not familiar with Xcode bundles.

plawrence
Contributor II

@sancheeto

If you install Xcode on your computer, open the project file and run a Build, it will create binary which you can then put into /usr/local/bin on your machines to use. I had to dig the binary out of my ~/Library/Developer folder.

I've then setup some login scripts to populate the sidebar on first user login.

chrisbju
New Contributor III

@plawrence How did you manage to script the adding ?

plawrence
Contributor II

@chrisbju

After copying the mysides binary into /usr/local/bin/ I add the following code to my login script so that it only makes the modifications to the sidebar once per user.

# Add Sidebar Shortcuts
if [ ! -e /Users/$3/.sidebarshortcuts ]
  then
    echo "Adding Sidebar Shortcuts"
    su - $3 -c "/usr/local/bin/mysides add Movies file:///Users/$3/Movies"
    su - $3 -c "/usr/local/bin/mysides add Music file:///Users/$3/Music"
    su - $3 -c "/usr/local/bin/mysides add Pictures file:///Users/$3/Pictures"
    su - $3 -c "/usr/local/bin/mysides add $3 file:///Users/$3"
    touch /Users/$3/.sidebarshortcuts
fi

maziboss
New Contributor

Hi, I'm a new here so please forgive me a stupid question :) I created mysides files, put it to usr/local/bin, wrote script and no idea why it doesn't work when I created pkg file in Composer (version 9.82). If I run script in terminal separately with sudo name_of_script.sh, put password, everything is ok. Below my settings in Composer and script code below:

Composer: mysides file attribute owner: user group: wheel Attributes of folders without change Script type: postinstall
#!/bin/sh if [ -e "/Users/$SUDO_USER/.sidebarshortcuts" ] then mysides add Music "file:///Users/$SUDO_USER/Music" mysides add Movies "file:///Users/$SUDO_USER/Movies" mysides add $SUDO_USER "file:///Users/$SUDO_USER" touch /Users/$SUDO_USER/.sidebarshortcuts fi

@plawrence maybe you have a simple solution... :) Thank You in advance for your help.

plawrence
Contributor II

@maziboss How/when are you running your script, do you have it as part of a policy triggering on Login? My example above it part of a login script, which is why I use the $3 variable, it puts the current username into that variable. I also make use of the 'su' command to run the mysides binary as the user (rather than root).

maziboss
New Contributor

@plawrence I don't know why your script doesn't work. Probably the problem is the $3 variable.
I made a policy with mysides file (dmg) and this script (disable if...):

#!/bin/bash

USERS=$(dscl . -list /Users | grep -v _ | grep -v root | grep -v nobody | grep -v daemon | grep -v Shared | grep -v hadmin)

for dir in $USERS
do
echo "$dir"
#if [ ! -e /Users/${dir}/.sidebarshortcuts ]
  #then
   echo "Adding Sidebar Shortcuts"
    su - "$dir" -c "/usr/local/bin/mysides add Movies file:///Users/${dir}/Movies"
    su - "$dir" -c "/usr/local/bin/mysides add Music file:///Users/${dir}/Music"
    su - "$dir" -c "/usr/local/bin/mysides add Pictures file:///Users/${dir}/Pictures"
    su - "$dir" -c "/usr/local/bin/mysides add ${dir} file:///Users/${dir}"
    touch /Users/${dir}/.sidebarshortcuts
#fi
done

and everything works correctly.
To check polisy, in terminal I used the command: sudo jamf policy -trigger Login

Sanchi
Contributor

Hi guys,

I've got mysides working by calling it from a Launch Agent. What I'd like to do is to remove All My Files.

I've got the script as an at Login Policy in the JSS and its doing a job but not totally. Below is what I'm doing to clear out the sidebar but All My Files remains. I got the file path addresses using the information found when you type "mysides list" into Terminal.

This is how it looks at the moment:

#!/bin/bash

USERS=$(dscl . -list /Users | grep -v _ | grep -v root | grep -v nobody | grep -v daemon | grep -v Shared | grep -v hadmin)

for dir in $USERS
do
echo "$dir"
#if [ ! -e /Users/${dir}/.sidebarshortcuts ]
  #then
   echo "Adding Sidebar Shortcuts"

    su - "$dir" -c "/usr/local/bin/mysides remove All My Files file:///System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries/myDocuments.cannedSearch/"
    su - "$dir" -c "/usr/local/bin/mysides remove iCloud x-apple-finder:icloud"
    su - "$dir" -c "/usr/local/bin/mysides remove AirDrop nwnode://domain-AirDrop"
    su - "$dir" -c "/usr/local/bin/mysides remove Movies file:///Users/${dir}/Movies"
    su - "$dir" -c "/usr/local/bin/mysides remove Music file:///Users/${dir}/Music"   
    su - "$dir" -c "/usr/local/bin/mysides remove Desktop file:///Users/${dir}/Desktop"   
    su - "$dir" -c "/usr/local/bin/mysides remove Documents file:///Users/${dir}/Documents"   
    su - "$dir" -c "/usr/local/bin/mysides remove Downloads file:///Users/${dir}/Downloads"     
    su - "$dir" -c "/usr/local/bin/mysides remove All My Files file:///System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries/myDocuments.cannedSearch/"
    su - "$dir" -c "/usr/local/bin/mysides insert ${dir} file:///Users/${dir}"    

    touch /Users/${dir}/.sidebarshortcuts
#fi
done

All My Files is the only one that won't disappear - could it be because the file path is referencing a System folder location or that the file path points to a location inside an app bundle (Finder)?

Any ideas to kill off AirDrop @maziboss?

mattm
New Contributor

Hi @sancheeto

MySides requires that you use quotation marks when handling spaces in the Shortcut name. So instead of using All My Files, try "All My Files" instead. To remove AirDrop use domain-AirDrop instead of just AirDrop. Hope this helps.

jayd_ch
New Contributor

I saw this forum entry and wanted something to know about the sfl files but unfortunately I found nothing in google. So I just searched on my system to configure those favorites easly and I found something...

In /usr/bin/ there is a tool named "sfltool", there is no man page and it was hard to get the commands working but I did it.

In my case it justs adds a sidebar item or a favorite network share, I have no idea how to restore or delete one.

sidebaritem: /usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///"pathtofolder"
favorite networkshare: /usr/bin/sfltool add-item -n “Displayname” com.apple.LSSharedFileList.FavoriteServers “Serverpath”

there is also a restore command "sfltool restore" I have no idea how it works but maybe someone else takes a look into that

bpavlov
Honored Contributor

nice find @jayd.ch
frogor aka mikeymikey aka pudquick aka .... does he go by any thing else?

anyways, he made this which may be helpful:
https://gist.github.com/pudquick/b85fcfd4a0479810e6aa

Sanchi
Contributor

@mattm Heres what I went with in the end. I had to escape the spaces for All My Files rather than use quote marks.

#!/bin/bash

USERS=$(dscl . -list /Users | grep -v _ | grep -v root | grep -v nobody | grep -v daemon | grep -v Shared | grep -v hadmin)

for dir in $USERS
do
echo "$dir"
#if [ ! -e /Users/${dir}/.sidebarshortcuts ]
  #then
   echo "Adding Sidebar Shortcuts"

    su - "$dir" -c "/usr/local/bin/mysides remove All My Files file:///System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries/myDocuments.cannedSearch/"
    su - "$dir" -c "/usr/local/bin/mysides remove iCloud x-apple-finder:icloud"
    su - "$dir" -c "/usr/local/bin/mysides remove domain-AirDrop nwnode://domain-AirDrop"
    su - "$dir" -c "/usr/local/bin/mysides remove Movies file:///Users/${dir}/Movies"
    su - "$dir" -c "/usr/local/bin/mysides remove Music file:///Users/${dir}/Music"   
    su - "$dir" -c "/usr/local/bin/mysides remove ${dir} file:///Users/${dir}"
    su - "$dir" -c "/usr/local/bin/mysides add ${dir} file:///Users/${dir}"
    su - "$dir" -c "/usr/local/bin/mysides add Desktop file:///Users/${dir}/Desktop"
    su - "$dir" -c "/usr/local/bin/mysides add Documents file:///Users/${dir}/Documents"
    su - "$dir" -c "/usr/local/bin/mysides add Downloads file:///Users/${dir}/Downloads"
    su - "$dir" -c "/usr/local/bin/mysides add Movies file:///Users/${dir}/Movies"
    su - "$dir" -c "/usr/local/bin/mysides add Music file:///Users/${dir}/Music"
    su - "$dir" -c "/usr/local/bin/mysides add Pictures file:///Users/${dir}/Pictures"    
# add a folder for inclusion in the sidebar and also the Dock by calling dockutil
    mkdir /Users/Shared/Workspace
# make the new folder writable by anyone
    chmod 777 /Users/Shared/Workspace
# add new folder to the sidebar
    su - "$dir" -c "/usr/local/bin/mysides add Workspace file:///Users/Shared/Workspace"
# add folder to th end of the Dock replacing the default Downloads folder
    /usr/local/bin/dockutil --add '/Users/Shared/Workspace/' --replacing 'Downloads' --allhomes

    touch /Users/${dir}/.sidebarshortcuts
#fi
done

I scrapped the idea of the Launch Agent and use the Once per User per Computer @ login trigger in the JSS and attached this as an "After" script. Everything works well for Yosemite and El Capitan.

Mysides has been really good but I'm also going to check into @jayd.ch s find as it looks very interesting.

shu
New Contributor

@jayd.ch Is there a way to use com.apple.LSSharedFileList.FavoriteItems to work on a network share?

chrisbju
New Contributor III

@shu add /Volumes :)

shu
New Contributor

@chrisbju Perfect. Thanks!!!

jayd_ch
New Contributor

@shu Yes you can do it, first you need to check if the specific network share is mounted, then you can use "file:///Volumes/"mounted network share name"/path/to/folder" at the end of the command

And if you unmount the network share and if you click on the sidebar item it should prompt the login window for the network share or the folder if you saved your password in your keychain. First I was concerned about this because it uses a local path, but if you remount a network share via sidebar item it knows the server path somehow..

jamestoher
New Contributor III

@jayd.ch It seems that /usr/bin/sfltool add-item will happily create duplicates in the Favorite Servers list.

But apparently we can use the dump-storage option first, to check whether the item already exists:

#!/bin/sh

/usr/bin/sfltool dump-storage ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.FavoriteServers.sfl | awk '{print $NF}' | sort -u | sed -ne 's/^URL://p'

davidwbeaty
New Contributor II

You must first connect to your network share (in this case we were connecting to a network share) for this to work:

sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Volumes/NameOfShare

Working in 10.11.6

tjb2
New Contributor

Does anyone know how I can remove all my favorites from my Finder Sidebar quickly? At work I use the sidebar to store where the job lives on our server, I work on some 20 jobs a day, I never have deleted any, now my finder is supper sluggish, I think it is because of the hundreds and hundreds of favorites in my sidebar. I don't want to turn my sidebar off, all I want to do is delete all favorites in one step, and now having to right click on each one saying to remove.
I may post this other areas, since I'm eagerly wanting a solution, my last resort will be to create a new user.

apizz
Valued Contributor

@tjb2 Are you talking about sidebar items under Favorites, like Documents? Or does this include servers? Personally I've not heard of issues with the Finder related to having too many favorites.

We use mysides for quickly removing all sidebar favorites. A mysides remove all will do the trick.

rodders
New Contributor III

Apologies fro reviving an old topic but: How are people adding Macintosh HD and removing "recent tags"?

joshuaaclark
Contributor

Updated for 10.13 since sfltool has been stripped of its usefulness. Removes "recent tags", hides tags in sidebar, hides shared in sidebar, hides external servers and drives from desktop.

#!/bin/bash
# Script uses mysides ( https://github.com/mosen/mysides ) to clear the sidebar and add our prefs.
# Our script is run by the local user in conjunction with other applescripts wrapped in an app
# before deployment to the end-user

# Get the Username of the currently logged user
loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

# Removes all sides and adds /Applications, User Desktop, Documents, Downloads, Home Folder
if [ -e /usr/local/bin/mysides ]
MYSIDES="/usr/local/bin/mysides"
then
    $MYSIDES remove all
    $MYSIDES add Applications file:///Applications 
    $MYSIDES add Desktop file:///Users/$loggedInUser/Desktop 
    $MYSIDES add Documents file:///Users/$loggedInUser/Documents 
    $MYSIDES add Downloads file:///Users/$loggedInUser/Downloads 
    $MYSIDES add $loggedInUser file:///Users/$loggedInUser 
    touch /Users/$loggedInUser/.sidebarshortcuts
fi

# Hides Tags
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder ShowRecentTags -bool FALSE     
# Hides External Drives on Desktop      
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder ShowExternalHardDrivesOnDesktop -bool FALSE
# Hides Server on Desktop
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder ShowMountedServersOnDesktop -bool FALSE
# Hides Shared section on SideBar
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder SidebarSharedSectionDisclosedState -int 0
# Sets Default Finder window to open at Computer showing root HD, connected external drives, and connected servers instead of Recents
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder NewWindowTarget PfCm
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.finder NewWindowTargetPath PfCm

killall Finder

jhuls
Contributor III

@joshuaaclark So mysides is working reliably for you with 10.13? The last time I worked with it was macOS 10.12 where it didn't reliably work and seemingly crashed. I might take another look at it if this is the case but it might be tough to trust.

fgonzale
Contributor

@jhuls I didn't try the pkg for the version of mysides 1.0.1 that was being distributed but compiling with Xcode from latest master branch code (which also seems to add a new "Insert" option for placing an item at the start of the favorites list) is working great for me in 10.14.5.

I already had a mounting script for a user's SMB home drive so I've simply added the following code at the end of that to add their SMB home drive to their favorites list upon login (the shell script is activated via a LaunchAgent item):

#remove any existing home drive icon from side bar favorites to avoid duplicates
/Library/Payloads/mysides remove $USER

#add home drive icon to side bar favorites
/Library/Payloads/mysides add $USER file:///Volumes/$USER

Easy Peasy

apizz
Valued Contributor

mysides 1.0.1 package still works for us on 10.14.5