Posted on 06-13-2016 07:15 AM
So, el capitan has a new binary called sfltool. It has been discussed a few times, and I have incorporated it into my firstrun script to add items to the sidebar. I think many more uses for this will be discovered.
Here is my script as an example.
#!/bin/bash
# Get the Username of the currently logged user
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
if [ -e /usr/local/bin/mysides ]
then
su - "$loggedInUser" -c "/usr/local/bin/mysides remove All My Files file:///System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries/myDocuments.cannedSearch/" && sleep 2
su - "$loggedInUser" -c "/usr/local/bin/mysides remove iCloud x-apple-finder:icloud" && sleep 2
su - "$loggedInUser" -c "/usr/local/bin/mysides remove domain-AirDrop nwnode://domain-AirDrop" && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Desktop && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Documents && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Downloads && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Movies && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Music && sleep 2
/usr/bin/sfltool add-item com.apple.LSSharedFileList.FavoriteItems file:///Users/$loggedInUser/Pictures && sleep 2
touch /Users/$loggedInUser/.sidebarshortcuts
fi
/usr/libexec/PlistBuddy -c "Add :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.backToMyMacEnabled bool False" /Users/$loggedInUser/Library/Preferences/com.apple.sidebarlists.plist
/usr/libexec/PlistBuddy -c "Add :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.bonjourEnabled bool False" /Users/$loggedInUser/Library/Preferences/com.apple.sidebarlists.plist
killall cfprefsd
Posted on 07-16-2019 08:38 AM
Hi @korylprince
I tried running the most recent version of your script from your GitHub page, but I'm getting the error:
" File "./connecttoserver_v2.py", line 20
"Get users with a home directory in /Users"
^
IndentationError: expected an indented block"
Am I doing something wrong?
Edit: Nevermind, I just don't know how to use GitHub properly...
Thanks,
Noah Blair
Posted on 10-31-2019 09:12 AM
@korylprince this was working great up until Catalina. But I guess some Python functionality has been deprecated, including the Foundation module. Do you happen to have a workaround for this? And thank you for creating this script to begin with, it's been a total lifesaver for me.
Thanks,
Chris
Posted on 11-01-2019 01:08 PM
If the sidebar is all you care about @tuck.itadmin have you tried mysides? We're not on Catalina but still works great on Mojave (10.14.6)
Posted on 02-26-2020 11:40 AM
I'm just now getting to testing this with Catalina. Catalina didn't remove python, just deprecated it; so we're fine for now. When it's gone we'll have to come up with another alternative (maybe a compiled Swift app?)
My scripts work, however there are some caveats. If you try to run the script directly in terminal, you'll find it runs, but it doesn't work. It turns out the com.apple.sharedfilelist directory is now protected along with the other security improvements in Catalina. To get it to run, you have to enable full disk access for terminal in the Security & Privacy settings.
I have not yet attempted to run the script in an automated process, so I'm not sure what, if any, hoops you'll have to jump through to get it to run properly.
Posted on 02-17-2022 01:39 PM
By chance has anyone updated this handy script for Python3? I am seeing an error:
File "configureServerFavorites.py", line 123, in <module>
item["Name"] = unicode(server)
NameError: name 'unicode' is not defined
Posted on 02-22-2022 11:57 AM
Figured it out: Python3 doesn't need Unicode to be explicitly defined as Python2 did - it supports Unicode by default. So I changed type 'unicode' to type 'str' and resolved the issue.
Posted on 04-08-2022 06:50 AM
Hi @korylprince,
Any chance you have an update on this awesome script? Looks like 12.3 and up said bye to Python 2. Here's the error now:
Posted on 04-08-2022 07:23 AM
12.3 said goodbye to all versions of python. Going forward you'll need to install it yourself if you want to use python.
Posted on 04-15-2022 01:25 PM
I've updated the scripts and tested them on successfully on 12.3.1 with Munki's python. Make sure to read the comments there. I'm also working on a compiled solution to this so python won't be required, but have no ETA on when that will be ready.
Posted on 04-20-2022 05:02 PM
Has anyone gotten this to work with Python3?