Looking to hide dock and menu bar

cwaldrip
Valued Contributor

Dockutil doesn't seem to offer to change the dock hiding settings. I've tried defaults write com.apple.Dock autohide 1, but it doesn't seem to do anything with killall cfprefsd and killall dock.

And I've tried defaults write .GlobalPreferences.plist _HIHideMenuBar 1 with killall cfprefsd and killall SystemUIServer to hide the menu bar too. But that doesn't seem to work reliably.

Those are the values changed if I change them through the UI. Is there anything I'm missing?

2 REPLIES 2

alex_guarino
New Contributor II

Did you ever figure this out?

mm2270
Legendary Contributor III

The Dock autohide setting is actually a boolean value, so setting it to "1" in a defaults command isn't going to activate it. The Dock will ignore the setting. The correct command would be something like defaults write com.apple.dock autohide -bool true But even that isn't going to work since, when a defaults command uses the shortened URL as it's target (meaning not the full path to the plist), it's going to affect the plist for the account running the command, which in the case of a Jamf Pro policy would be root, not the currently logged in user. The Dock settings are user based, so you would probably need to get the logged in user's name and home directory path and then doing the defaults write to their dock.plist.

logged_in_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ {print $3}')
/usr/bin/defaults write /Users/$logged_in_user/Library/Preferences/com.apple.dock.plist autohide -bool true
killall cfprefsd && killall dock

It's going to be basically the same deal with the hide menu bar setting. It's a boolean value, so the "1" you see when reading it with defaults indicates true. Something like defaults write /Users/$logged_in_user/Library/Preferences/.GlobalPreferences.plist _HIHideMenuBar -bool true should do it.

It might also be possible to put these settings into a Configuration Profile, but Dock profiles tend to make the Dock immutable. I'm not sure if just setting those values would cause it to become immutable though.