How can I deploy bookmarks to safari with Casper?

EL-IT
New Contributor

I am trying to push out favorites/bookmarks to Safari with Casper, instead of me going to each individual laptop and adding a link to the bookmark section for a cart of 30 laptops everytime they want a new site added.

9 REPLIES 9

dmohs
Contributor

I do not have an answer, but long before we used Casper, I gave up on such a task.

Instead, I suggest that people publish all the links somewhere on their organization's website (or Schoology, etc). It makes managing bookmarks much easier.

bentoms
Honored Contributor III
Honored Contributor III

Hi EL-IT.

Like @dmohs, I tried & gave up adding to the standard bookmarks.

Instead, on the advise on someone on MacE, I created a Safari toolbar & we deploy that.

scottb
Honored Contributor

Well, a rinky-dink "solution" would be to add them to the Self Service app. Unless your site list is really long, it would work. You could make them launch the browser instead of using Self Service and it would at least work.

Nix4Life
Valued Contributor

I was just looking at this today.for better or worse,were going with a folder in the dock with the links and stacks set to list. you could always create a policy to add new link at login or boot. again just an idea i am playing with, may also have puppet update the folder, we'll see just my 2 cents

LSinNY

John_Wetter
Contributor II

Add another one to the list of "tried that, won't go back." We just have buildings/departments have a web page with all of their links and make that page be the default. Then they've got them all in a fairly unobtrusive way.

Not applicable

The last time I turned up Comcast service, part of their activation process ran a script (python iirc) that added bookmarks to my browsers. If I kept a copy of that script, I'll post it - maybe someone with more python-fu can get something useful out of it..

themacdweeb
Contributor

my bash script is from about a year ago. it was challenging because of all the odd .plist manipulations required. python is far better at working with plists than bash. edit as you like. our version logs itself, timestamps itself for easy viewing in console later. additionally, it cycles through EACH user account so we're sure to hit everyone on that mac. lastly, the script adds a bookmark to the FIRST location on the bookmark bar: on the far left. Haven't used in a while so YMMV:

#!/bin/sh

# script to add a bookmark to the FRONT LEFT of the safari bookmark bar
# for all > 500 user accounts.
# to create your own links, just change the variables:
#
# LinkTitle = the name of the link you'd like to appear in your link bar
# LinkURL = the actual link to which you'll surf
# Bookmakrs = the Safari bookmarks file(s) to which you'll be adding the link
# LOG = whatever your sdout file is

# many thanks to both Chris Norris (cnorris@getty.edy) & Ryan Manly (ryan.manly@gmail.com) for their invaluable input.

#----------------------------------------------------------
#   Variables
#----------------------------------------------------------

# --- assignments ---
SCRIPTNAME=$0
LinkTitle="eAppraisal"
LinkURL="https://thislinkisamazing.com/index.jsp"

# --- executables ---
Plist="/usr/libexec/PlistBuddy"

# --- directories ---
LOG="/Library/Logs/Whatever.Your.Log.File.Is"

# --- computationals ---
date=`date "+%A %m/%d/%Y %H:%M"`
over500=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`

# ---------------------------------------------------------------------------
#   Cycle through all users, backs up safari bookmarks & adds new link
# ---------------------------------------------------------------------------
for i in $over500
do
    cd /Users/$i/Library/Safari
    zip BookmarksBackup.zip Bookmarks.plist
    echo "backup of bookmarks SUCCESSFUL for the $i account." >> $LOG
    $Plist Bookmarks.plist -c "Add :Children:1:Children:0 dict" >> $LOG
    $Plist Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary dict" >> $LOG
    $Plist Bookmarks.plist -c "Add :Children:1:Children:0:URIDictionary:title string ${LinkTitle}" >> $LOG
    $Plist Bookmarks.plist -c "Add :Children:1:Children:0:URLString string ${LinkURL}" >> $LOG
    $Plist Bookmarks.plist -c "Add :Children:1:Children:0:WebBookmarkType string WebBookmarkTypeLeaf" >> $LOG
done

exit 0

bentoms
Honored Contributor III
Honored Contributor III

alexjdale
Valued Contributor III

I figured out how to add and populate a folder as well. Items are added to the folder in reverse order.

#!/bin/sh

over500=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`

addBookmark() {
    LinkTitle=$1
    LinkURL=$2
    userName=$3
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children:0 dict"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children:0:URIDictionary dict"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children:0:URIDictionary:title string ${LinkTitle}"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children:0:URLString string ${LinkURL}"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children:0:WebBookmarkType string WebBookmarkTypeLeaf"
}

createFolder() {
    folderName=$1
    userName=$2
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0 dict"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Children array"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:WebBookmarkType string WebBookmarkTypeList"
    /usr/libexec/PlistBuddy /Users/$userName/Library/Safari/Bookmarks.plist -c "Add :Children:1:Children:0:Title string ${folderName}"
}

# Run for each user
for i in $over500; do
    echo "Processing user $i"
    if [ ! "$(grep "<string>CompanyLinks</string>" /Users/$i/Library/Safari/Bookmarks.plist)" ]; then
        zip /Users/$i/Library/Safari/BookmarksBackup.zip /Users/$i/Library/Safari/Bookmarks.plist
        echo "backup of bookmarks SUCCESSFUL for the $i account."
        createFolder "CompanyLinks" $i
        addBookmark "Link 2 Title" "https://link2" $i
        addBookmark "Link 1 Title" "https://link1" $i
    else
        echo "User $i appears to already have the CompanyLinks bookmark folder, skipping"
    fi
done