Dockutil and Monterey - Cannot figure out what is wrong.

kwoodard
Contributor III

I have been using dockutil for years without issue. I have historically been putting the shell script in the Users/Shared/bin folder and the plist in the user LaunchAgent folder. Like I said, years have been working...

Now that Python is not installed by default and using the newest version of Dockutil, I cannot get it to run. I have tried to get this to run via Jamf. I have used Jamf to dump the two files into their respective homes on the endpoint. Heck, I have even manually added the files to a target computer just for testing. All I get is an "unable to execute (path to .sh file) Operation not permitted. I don't know what I am doing wrong, but it's making my hair fall out.

Here are my scripts...

#!/bin/zsh

dockutilbin=$(/usr/local/bin/dockutil)
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUserPlist="/Users/$loggedInUser/Library/Preferences/com.apple.dock.plist"

$dockutilbin --remove all --no-restart $loggedInUserPlist; sleep 2
$dockutilbin --add file:///System/Applications/Launchpad.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Safari.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Google\ Chrome.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Bridge\ 2022/Adobe\ Bridge\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Photoshop\ 2022/Adobe\ Photoshop\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Lightroom\ Classic/Adobe\ Lightroom\ Classic.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Illustrator\ 2022/Adobe\ Illustrator.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Premiere\ Pro\ 2022/Adobe\ Premiere\ Pro\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Substance\ 3D\ Designer/Adobe\ Substance\ 3D\ Designer.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Adobe\ Substance\ 3D\ Painter/Adobe\ Substance\ 3D\ Painter.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Autodesk/maya2023/Maya.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/TVPaint\ Animation\ 11.5\ Pro.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/Corel\ Painter\ 2021/Corel\ Painter\ 2021.app/ --no-restart $loggedInUserPlist
$dockutilbin --add file:///Applications/VLC.app/ --no-restart $loggedInUserPlist
$dockutilbin --add '/Applications/' --view grid --display folder --sort name --no-restart $loggedInUserPlist
$dockutilbin --add '~/Downloads/' --view fan --display folder --sort name $loggedInUserPlist

exit 0

defaults write com.apple.dock tilesize -int 40
defaults write com.apple.dock magnification -bool true

exit 0

 Here is the plist that should be triggering everything...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<dict>
		<key>SuccessfulExit</key>
		<false/>
	</dict>
	<key>Label</key>
	<string>TEST</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Users/Shared/bin/test.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

 I will say that only one time did the dock update to include the items listed in the script above. It just added them to the default list that populates the dock out of the box. I have never been able to reproduce it.

What am I missing?

Ultimately I would love to have this script run from Jamf so I don't have to use the script and plist files on the computer. Docutil is installed on every computer I manage...

Before Monterey, this is the script that worked... It worked a treat too. Dock would show up for a second with just the trash can, blink off, then blink back on as requested with the settings and everything.

#!/bin/bash

# Running checkSetupDone function to determine if the rest of this script needs to run.
# Yes, if $HOME/Library/Preferences/com.ARC.docksetup.plist file does not exist.
# Otherwise, assume this setup script has already run for this user and does not
# need to run again.



checkSetupDone()    {

    if [ -f $HOME/Library/Preferences/com.ARC.docksetup.plist ] ; then
        exit 0
    fi

}

configureDefaultDock()  {

    DOCKUTIL=/usr/local/bin/dockutil


    $DOCKUTIL --remove all --no-restart

    $DOCKUTIL --add '/System/Applications/Launchpad.app' --no-restart

    $DOCKUTIL --add '/Applications/Safari.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Google Chrome.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Bridge 2022/Adobe Bridge 2022.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Photoshop 2022/Adobe Photoshop 2022.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Lightroom Classic/Adobe Lightroom Classic.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Illustrator 2022/Adobe Illustrator.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Premiere Pro 2022/Adobe Premiere Pro 2022.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Substance 3D Designer/Adobe Substance 3D Designer.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Adobe Substance 3D Painter/Adobe Substance 3D Painter.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Autodesk/maya2023/Maya.app' --no-restart
    
    $DOCKUTIL --add '/Applications/TVPaint Animation 11.5 Pro.app' --no-restart
    
    $DOCKUTIL --add '/Applications/Corel Painter 2021/Corel Painter 2021.app' --no-restart
    
    $DOCKUTIL --add '/Applications/VLC.app' --no-restart
    
    $DOCKUTIL --add '/Applications' --view grid --display folder --sort name

    touch $HOME/Library/Preferences/com.ARC.docksetup.plist

}

checkSetupDone
configureDefaultDock

defaults write com.apple.dock tilesize -int 40
defaults write com.apple.dock magnification -bool true

exit 0

  

8 REPLIES 8

kwoodard
Contributor III

I will also say, that if I run my "old" script from the desktop using terminal and sudo, it mostly works. It won't turn on magnification or shrink the dock in size. 

bizzaredm
Contributor

For the old script, the magnification  and size should work after a killall Dock command and you may have to killall cfprefsd first

$ defaults write com.apple.dock magnification -bool true
$ killall cfprefsd                                      
$ killall Dock   

 

 

I figured out the part with size and magnification... With Monterey (and I am guessing Big Sur) you have to run those commands as the signed in user, otherwise they are run as root.

loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ {print $3 }' )
sudo -u "$loggedInUser" defaults write com.apple.dock magnification -bool true

 

Still cannot get it to run at load. I thought if the plist was put into the /Library/LaunchAgent folder, it would run at load for every user. It seems that I have to put it into the one inside the English.lproj folder. I have made sure that the plist has been updated to point at the path of the script...no such luck so far. Been working on this for a couple weeks now.

bizzaredm
Contributor

Also, why does the new script use the --add file? From the git page it seems like the old script is more correct..

  The following adds TextEdit.app to the end of the current user's dock:
           dockutil --add /Applications/TextEdit.app

 

I would think using the new script would be fine using the old scripts method for each command.

Overall, the new script should be able to be run from jamf assuming the user is logged in. 

I tested the old script and it worked for me directly with terminal, including size and magnification. 

Everything completely fails if I run zsh via terminal with the script unless i change 

dockutilbin=$(/usr/local/bin/dockutil)
to
dockutilbin='/usr/local/bin/dockutil'

That's interesting... I will play with that. 

At this point though, the old script runs as it should manually... I need to get it to run when a user signs in. That is elusive at the moment.

bizzaredm
Contributor

Hopefully this helps...

I tested this via jamf and locally, except for the defaults write... and it worked

getting it to run via the launchd is the next step.    Might be a simple permissions issue.

#!/bin/zsh

dockutilbin='/usr/local/bin/dockutil'
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUserPlist="/Users/$loggedInUser/Library/Preferences/com.apple.dock.plist"

$dockutilbin --remove all --no-restart $loggedInUserPlist; sleep 3
$dockutilbin --add /System/Applications/Launchpad.app --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Safari.app --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Google\ Chrome.app --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Bridge\ 2022/Adobe\ Bridge\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Photoshop\ 2022/Adobe\ Photoshop\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Lightroom\ Classic/Adobe\ Lightroom\ Classic.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Illustrator\ 2022/Adobe\ Illustrator.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Premiere\ Pro\ 2022/Adobe\ Premiere\ Pro\ 2022.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Substance\ 3D\ Designer/Adobe\ Substance\ 3D\ Designer.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Adobe\ Substance\ 3D\ Painter/Adobe\ Substance\ 3D\ Painter.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Autodesk/maya2023/Maya.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/TVPaint\ Animation\ 11.5\ Pro.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/Corel\ Painter\ 2021/Corel\ Painter\ 2021.app/ --no-restart $loggedInUserPlist
$dockutilbin --add /Applications/VLC.app --no-restart $loggedInUserPlist
$dockutilbin --add '/Applications/' --view grid --display folder --sort name --no-restart $loggedInUserPlist
$dockutilbin --add '~/Downloads/' --view fan --display folder --sort name --no-restart $loggedInUserPlist

defaults write /Users/$loggedInUser/Library/Preferences/com.apple.dock tilesize -int 40
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.dock magnification -bool ture

sleep 4

killall cfprefsd                                      
killall Dock

exit 0

  

I will try that. If I can get it to run via Jamf when a user logs in for the first time, that is all I need.