kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.36k stars 131 forks source link

Dockutil 3.02 hangs with macOS 12.5.1 #139

Open ArminDeeg opened 1 year ago

ArminDeeg commented 1 year ago

This postinstall script hangs endless with dockutil 3.0.2 any suggestions ? happens with macOS 12.5.1 Intel iMac 5K 2020

`#!/bin/sh

OLDIFS=$IFS IFS='.' read osvers_major osvers_minor osvers_dot_version <<< "$(/usr/bin/sw_vers -productVersion)" if [ ${osvers_major} = 10 ]; then /Users/Shared/Dockutil/dockutil --add /Applications/EXPOSÉ\ X\ Client/EXPOSE\ X\ Client.app "$HOME" echo 'docutil v2' else /Users/Shared/Dockutil/dockutil3 --add /Applications/EXPOSÉ\ X\ Client/EXPOSE\ X\ Client.app "$HOME" echo 'docutil v3' fi

exit 0`

Lotusshaney commented 1 year ago

Looks to be the same as https://github.com/kcrawford/dockutil/issues/126

Try running it in the user space

ArminDeeg commented 1 year ago

Looks to be the same as #126

Try running it in the user space

wow fast answer, thanks.

Do you have a sample to avoid try and error for me?

Thanks Armin

Lotusshaney commented 1 year ago

Have a look here,

https://scriptingosx.com/2020/08/running-a-command-as-another-user/

ArminDeeg commented 1 year ago

I tried this with your hint.

it works when I drag the postinstall script in the terminal window. But when I use it from a pkg installer as postinstall it does not work. But a tiny success, docutil does not hangs anymore. But the desired icon was not created inside the dock.

'#!/bin/sh

currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
/Users/Shared/Dockutil/dockutil3 --add /Applications/EXPOSÉ\ X\ Client/EXPOSE\ X\ Client.app /Users/$currentUser/Library/Preferences/com.apple.dock.plist

exit 0'

Lotusshaney commented 1 year ago

you need to run the dockutil command as the user. Your example is not doing that, its just getting the current user

Lotusshaney commented 1 year ago
#!/bin/sh

#Define Func
runAsUser() {
    currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
    uid=$(id -u "$currentUser")  
    if [ "$currentUser" != "loginwindow" ]; then
        launchctl asuser "$uid" sudo -u "$currentUser" "$@"
    fi
}

runAsUser /Users/Shared/Dockutil/dockutil3 --add /Applications/EXPOSÉ\ X\ Client/EXPOSE\ X\ Client.app /Users/$currentUser/Library/Preferences/com.apple.dock.plist

exit 0
ArminDeeg commented 1 year ago

Thank

got it working with this script:

https://github.com/mvdbent/setDock/blob/main/setDock-addToDock.sh

looks similar to your one

Armin

GitSweetDragon commented 1 year ago

Hello,

i have tried https://github.com/mvdbent/setDock/blob/main/setDock-addToDock.sh and get this error :

Script exit code: 1

Script result: Dockutil version = 3.0.2no appPath set Error running script: return code was 1.

i used jamf pro 10.42

i have also tried ths but nothing append except relaod dock

#!/bin/zsh

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

# Create a clean Dock
dockutil --remove all --no-restart
echo "clean-out the Dock"

# Setup dock, in various examples
dockutil --add /System/Applications/System\ Preferences.app --position 1 --no-restart
dockutil --add /Applications/DisplayLink\ Manager.app --position 2 --no-restart
dockutil --add /Applications/Self\ Service.app  --position 3 --no-restart
dockutil --add /System/Applications/Calculator.app --position 4 --no-restart
dockutil --add /Applications/Safari.app --after 'Calculator' --no-restart
dockutil --add /Applications/Google\ Chrome.app --after 'Safari' --no-restart
dockutil --add /Applications/Microsoft\ Teams.app --after 'Google Chrome' --no-restart
dockutil --add /Applications/Microsoft\ Outlook.app --after 'Microsoft Teams' --no-restart
dockutil --add /Applications/Microsoft\ Word.app --after 'Microsoft Outlook' --no-restart
dockutil --add /Applications/Microsoft\ Excel.app --after 'Microsoft Word' --no-restart
dockutil --add /Applications/Microsoft\ PowerPoint.app --after 'Microsoft Excel' --no-restart
dockutil --add /System/Applications/Utilities/Screenshot.app --before 'Self Service' --no-restart
dockutil --add '/Applications' --view grid --display folder --allhomes
dockutil --add '~/Desktop' --view grid --display folder --allhomes
dockutil --add '~/Downloads' --view grid --display folder --allhomes

exit 0

Or how to user DockUtil.swift with jamf please ?

mvught commented 1 year ago

Use the script from mvdbent that's working, make it easy and simple 😉

GitSweetDragon commented 1 year ago

@mvught thanks but it's not working for me. i create m repo https://github.com/GitSweetDragon/dockutil i don't how to share it

mvught commented 1 year ago

is this your script? dockutil_corp-settings.sh? in the repo?

GitSweetDragon commented 1 year ago

is this your script? dockutil_corp-settings.sh? in the repo?

On this repo "GitSweetDragon" ? Yes

mvught commented 1 year ago

Ok man I read your story and I can help you. I have the same environment ass you are, wat you have to do: -First enroll the machine -After reboot use Outset to "run once login"

Outset you set de dock setting and other things if you like.

If you have slack you can pb me, and find me under the same name #macadmins channel and share you more.

let me know if this make sense to you and happy to help

GitSweetDragon commented 1 year ago

Thanks you ☺️. I don't have access to slack macadmin. I try to register but doesn't work.

mvught commented 1 year ago

First you need Outset: https://github.com/chilcote/outset/releases Make a package in Composer: image if have 3 in here but you can drop your Dock in there.

Deploy this 2 in your deployment!

Thats al you need ;) After enrollment you reboot and then login again and than boom ;)

mvught commented 1 year ago

And?