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.0.2 and Sonoma Beta 23A5276g #153

Open cipineda opened 1 year ago

cipineda commented 1 year ago

Hello, Started testing Sonoma in my environment and noticed a few issues.

1.- Adding/Removing with the --no-restart seems to have no effect anymore. 2.- Getting this error: Setting Dock for user cesar.sonoma... Error: /var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist Usage: dockutil [] [ ...] See 'dockutil --help' for more information. Error: /var/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist

The script works fine in Ventura, it seems something changed in Sonoma that dockutil does not like.

mvught commented 1 year ago

Tested it here and problem can you share your script

cipineda commented 1 year ago

setDockScript.sh.zip

mvught commented 1 year ago

Ok check this script: https://github.com/mvdbent/setDock/blob/main/setDock-defaultDock.sh run it and test it. I am 100% sure that if you incorporate your part in this everything will work properly!

cipineda commented 1 year ago

thanks!!!, I really appreciate it; will give it a try.

das197 commented 1 year ago

Hi @mvught, It keeps failing on Sonoma.

sh-3.2# sh /Users/UserA/Desktop/dockItems.sh Dockutil version = 3.0.2 clean-out the Dock adding /Applications/Slack.app /Users/UserA/Desktop/dockItems.sh: line 19: 37174 Trace/BPT trap: 5 launchctl asuser "$uid" sudo -u "${currentUser}" "$@" adding /Applications /Users/UserA/Desktop/dockItems.sh: line 19: 37186 Trace/BPT trap: 5 launchctl asuser "$uid" sudo -u "${currentUser}" "$@" Restarted the Dock Finished creating default Dock

pro4tlzz commented 9 months ago

Hi @mvught, It keeps failing on Sonoma.

sh-3.2# sh /Users/UserA/Desktop/dockItems.sh Dockutil version = 3.0.2 clean-out the Dock adding /Applications/Slack.app /Users/UserA/Desktop/dockItems.sh: line 19: 37174 Trace/BPT trap: 5 launchctl asuser "$uid" sudo -u "${currentUser}" "$@" adding /Applications /Users/UserA/Desktop/dockItems.sh: line 19: 37186 Trace/BPT trap: 5 launchctl asuser "$uid" sudo -u "${currentUser}" "$@" Restarted the Dock Finished creating default Dock

I'm also getting this BPT trap which I think is the cause of not getting the dock configured correctly.

Does anyone else face the same issue?

pro4tlzz commented 9 months ago

@das197

Try something like this

dockutil="/usr/local/bin/dockutil"
LOGGEDINUSER=$(stat -f '%Su' /dev/console)
uid=$(id -u "${LOGGEDINUSER}")

runAsUser() {  
    if [[ "${LOGGEDINUSER}" != "loginwindow" ]]; then
        launchctl asuser "$uid" sudo -u "${LOGGEDINUSER}" "$@"
    else
        echo "no user logged in"
        exit 1
    fi
}

if [ "$LOGGEDINUSER" == "root" ]; then
    echo "Currently logged in user is root - aborting."
    echo "------------------------------------------------------------"
    exit 1
fi

homeDirectory="/Users/$LOGGEDINUSER/"
runAsUser "$dockutil" --add "/Applications/Google Chrome.app" --no-restart "$homeDirectory"

Using the runasUser function helped

kcrawford commented 8 months ago

Are you able to reproduce the BPT trap error? Did you figure out what is/was causing the error?

pro4tlzz commented 8 months ago

Are you able to reproduce the BPT trap error? Did you figure out what is/was causing the error?

yes I reproduced it, no I didn't have a clue what caused it. When I tried to run the dockutil commands as sudo (current user) that didn't help. Eventually I tried Armin's way and it worked flawlessly.