Skip to main content
Question

Changes to com.apple.dock.plist

  • October 26, 2017
  • 1 reply
  • 2 views

Forum|alt.badge.img+1

Hello,

I am trying to push network mounts to the dock via com.apple.dock.plist.
(There is a Global version and a User version. I need to edit the user version located at /Library/Managed Preferences/Username/com.apple.dock.plist. Here is where apple has stored the users "Network Home" drive.)

My problem is that when I push the global version of this plist it erases all persistent-others and static-others from the array. So I am forced to edit the user version which is where I am stumped.

I need to change the contents of the plist:
bplist00”]static-others_ MCXDockSpecialFolders[static-apps°“ Ytile-typeYtile-dataXurl-tile‘

UlabelSurlYfile-dataTbookoUsername s Network Home“_CFURLStringType_CFURLStringsmb://domain.org/level1/users/level3/username/“O†book†0Dsmb://domain.com/level1/users/level3/username/$˛ˇˇˇ–°_#AddDockMCXOriginalNetworkHomeFolder†5ACHRentxÇá¿≈ÿÂÁºæ‰Â

I need this to have all the user information changed to variables so that it can be uses globally for all users.

1 reply

Forum|alt.badge.img+8

You haven't really provided helpful plist dump here (please use /usr/libexec/PlistBuddy -c "print" or defaults read for that), but I've had already a similar solution for users' standard, unmanaged preferences. This should be a great start for you, so have a look and adjust to your needs (persistent to static, paths etc.):

#!/bin/bash

# CONFIGURABLES:

ITEMNAME="Label of item to modify"

# PREREQUISITES:

PB="/usr/libexec/PlistBuddy"
MODIFIED_DOCK_ITEMS=0
USERS=$(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1;}')

# FUNCTIONS:

function modifyDockItem() {
    for U in "$USERS"; do
        if [ -d "/Users/$U" ]; then
            PLIST="/Users/$U/Library/Preferences/com.apple.dock.plist"
            for ((i=0;i>=0;i+=1)); do
                TILETYPE=$($PB -c "print:persistent-others:$i:tile-type" ${PLIST} 2> /dev/null)
                if [[ "$TILETYPE" == "url-tile" ]]; then
                    URLLABEL=$($PB -c "print:persistent-others:$i:tile-data:label" ${PLIST})
                    if [[ "${URLLABEL}" == "${1}" ]]; then
                        $PB -c "set:persistent-others:$i:tile-data:label ${U}'s Network Home" ${PLIST}
                        $PB -c "set:persistent-others:$i:tile-data:url:_CFURLString smb://domain.org/level1/users/level3/${U}" ${PLIST}
                        ((MODIFIED_DOCK_ITEMS++))
                        echo "Persistent ${1} item modified in ${U}'s dock."
                        break
                    fi
                else
                    break
                fi
            done
        fi
    done
}

# SCRIPT:

modifyDockItem "${ITEMNAME}"

# If at least one item has been modified in Dock, refresh it:
if [[ ${MODIFIED_DOCK_ITEMS} -ne 0 ]]; then
    echo "Refreshing Dock…"
    killall Dock
fi

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings