Skip to main content
Question

Adding Favourites Finder Sidebar

  • Mar 10, 2022 11:35 AM UTC
  • 5 replies
  • 112 views

rajrajan
Forum|alt.badge.img+8

Dear All,

I need a bash script for adding "Favourites Finder Sidebar items" in macOS Monterey or Custom Payload profile.

 

Please advise.

 

Thanks!

Raj.

5 replies

rajrajan
Forum|alt.badge.img+8
  • Author
  • Contributor
  • Mar 24, 2022 4:40 AM UTC

Dear All,

Please check the script below: It is not working when pushed from Jamf but working using the terminal.

 

Thoughts?

 

Thanks!

Raj.

#!/bin/sh

#Finds current username and defines a variable
currentuser=`stat -f "%Su" /dev/console`

#Substituting as user stored in variable to modify plist
#su "$currentuser" -c "<command to run>"

#Add Movies, Music, Pictures, <username>, to Finder Favorites sidebar.

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Applications"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Movies"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Music"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Pictures"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Downloads"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Documents"

#Restarts cfprefsd and Finder

killAll cfprefsd
killAll Finder

echo "Finder Preferences set"

exit 0


Forum|alt.badge.img+1
  • New Contributor
  • Apr 12, 2022 1:20 AM UTC

Hello Raj,

I am also trying to figure this out.I'd like to try and collaborate with this one, if you are still interested. Some questions I have for you...

Does this script require any 3rd party tools, or does it work for you using "vanilla" macOS?

Which macOS version have you tested this on where it works successfully?

Is there any more contextual technical information you can provide on what was required for this script work for you?

Thanks.


Forum|alt.badge.img+3
  • New Contributor
  • Apr 13, 2022 7:12 PM UTC

Dear All,

Please check the script below: It is not working when pushed from Jamf but working using the terminal.

 

Thoughts?

 

Thanks!

Raj.

#!/bin/sh

#Finds current username and defines a variable
currentuser=`stat -f "%Su" /dev/console`

#Substituting as user stored in variable to modify plist
#su "$currentuser" -c "<command to run>"

#Add Movies, Music, Pictures, <username>, to Finder Favorites sidebar.

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Applications"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Movies"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Music"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Pictures"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Downloads"

su "$currentuser" -c "mysides add com.apple.LSSharedFileList.FavoriteItems file:///Users/$currentuser/Documents"

#Restarts cfprefsd and Finder

killAll cfprefsd
killAll Finder

echo "Finder Preferences set"

exit 0


"mysides" is a separate application that can be installed via homebrew; it is not included by default on macOS.

If you distributed mysides first and then ran this script with the complete path to the binary (say /usr/local/bin/mysides), your changes should take effect.


Forum|alt.badge.img+1
  • New Contributor
  • Apr 22, 2022 6:36 PM UTC

"mysides" is a separate application that can be installed via homebrew; it is not included by default on macOS.

If you distributed mysides first and then ran this script with the complete path to the binary (say /usr/local/bin/mysides), your changes should take effect.


I can second this. I figured out how to use it, and it works. You can also install it from the "Releases" section on GitHub (Releases ยท mosen/mysides (github.com)). You may to re-sign the package using your Jamf Pro signing certificate (I had to do this), then deploy the signed package to your mcabooks. After it is deployed, you can create a script to run the mysides commands that you want.


cucaracha
Forum|alt.badge.img+5
  • Contributor
  • Dec 20, 2024 11:52 PM UTC

Great tool.

FYI, to clear the side bar and start fresh, use command "mysides remove all".