Dock not resetting to default state

CapU
Contributor III

In was testing a Dock layout for a few days. I decided to go back to the default settings I ran the command:
defaults delete com.apple.dock; killall Dock The dock disappears but does not reset to default. Does anyone have any ideas hoe to reset to default? Guess I will have to create a dock package and push it.
Any ideas would be apprciated

1 ACCEPTED SOLUTION

CapU
Contributor III

Ahhh All of you guys @mm2270 , @davidacland @thoule The suggestions are much appriciated.

!/bin/sh

for a in $(ls /Users/); do rm /Users/$a/Library/Preferences/com.apple.dock.plist 2>/dev/null
killall cfprefsd
killall Dock
done

Is what I ran and it worked

Thanks

View solution in original post

11 REPLIES 11

thoule
Valued Contributor II

You're likely trying to delete /Library/Preferences/com.apple.dock.plist You want to delete the one on your home directory (/Users/CapU/Library/Preferences/com.apple.dock.plist). If you have multiple users, you'll want to loop through them. -t-

mm2270
Legendary Contributor III

it depends on how you ran this command:

defaults delete com.apple.dock

If that was run directly in Terminal logged into your account, that would delete the Dock.plist for your account and should have reset the Dock.
If that was run from a policy, that's going to try to delete the Dock.plist from the root account, which isn't going to have any effect on your Dock.

If you did the former and not the latter, try throwing in a killall cfprefsd after the deletion, but before restarting the Dock. It may have just cached the previous Dock information and reloaded it.

davidacland
Honored Contributor II

I've only ever used defaults delete to delete keys within a plist file. If you want to completely reset it, you'll probably need to flush the preference cache first, then use rm on the file, then finally killall Dock.

mm2270
Legendary Contributor III

Hmm, good point @davidacland! You probably should rm the file and not use defaults delete here. Wasn't really paying attention when I read the post.

CapU
Contributor III

Thanks for the respopnse.
How do I "loop thru" again?
I know dumb question

mm2270
Legendary Contributor III

Basic idea:

#!/bin/sh

for a in $(ls /Users/); do
    rm /Users/$a/Library/Preferences/com.apple.dock.plist 2>/dev/null
done

davidacland
Honored Contributor II

You can set it as a policy to run at login for each user on each computer (depending where you need to reset it), using $3 as a variable for the username, i.e. /Users/$3/Library/...

CapU
Contributor III

I tested

!/bin/sh

for a in $(ls /Users/); do rm /Users/$a/Library/Preferences/com.apple.dock.plist 2>/dev/null
killall Dock
done

The dock never refreshed to the default state.

mm2270
Legendary Contributor III

As @davidacland already mentioned, you likely also need to do a killall cfprefsd in there or it will simply load from cache, not from disk. Its just "one of those things" we need to do to get around Apple's aggressive caching model.
If that isn't working, remove the 2>/dev/null from the rm line and run it again and see if it shows any errors. It might be balking at something.

mm2270
Legendary Contributor III

Also, are you certain you don't have a Configuration Profile controlling the Dock in play here? Please double check that, since no amount of deleting plists is going to help if your Dock is being managed by an immutable Dock config.

CapU
Contributor III

Ahhh All of you guys @mm2270 , @davidacland @thoule The suggestions are much appriciated.

!/bin/sh

for a in $(ls /Users/); do rm /Users/$a/Library/Preferences/com.apple.dock.plist 2>/dev/null
killall cfprefsd
killall Dock
done

Is what I ran and it worked

Thanks