kcrawford / dockutil

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

Folder options do not seem to work anymore #104

Closed remy-tiitre closed 3 years ago

remy-tiitre commented 3 years ago

After latest Big Sur update these options do not work anymore

folder_options:
  --view [grid|fan|list|auto]                                   stack view option
  --display [folder|stack]                                      how to display a folder's icon

Folders are always added with Stack and Automatic options.

Coros commented 3 years ago

same issue here. dockutil still functions on 11.3.1 but 11.4 is broken.

ferben commented 3 years ago

I have the same observation, it can by bug in macOS but we should consider new macOS behavior from version 11.4. Can anybody make test on macOS 11.5 beta for bug or behavior change confirmation?

rodchristiansen commented 3 years ago

I can confirm that this is not happening with Big Sur 11.5 beta 2

ferben commented 3 years ago

@rodchristiansen Thank you, so confirmed as bug in macOS 11.4.

cnelson644 commented 3 years ago

I created a workaround for now using PlistBuddy.

loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')

/usr/libexec/PlistBuddy -c "Set :persistent-others:<folder_order_in_array>:tile-data:displayas 1" "/Users/${loggedInUser}/Library/Preferences/com.apple.dock.plist"

- is the number in the array for the folder you want to edit under com.apple.dock.plist. So for example, if the first folder on your dock needs to be set, you put 0. Second folder, 1... I always put the same folders on my docks in labs so the order and number never change. I used a loop to do them all. `counter=0` `until [ $counter -gt 8 ]; do` `/usr/libexec/PlistBuddy -c "Set :persistent-others:${counter}:tile-data:displayas 1" "/Users/${loggedInUser}/Library/Preferences/com.apple.dock.plist"` `((counter++))` `done` The only issue is you have to wait for like 5-7 seconds after using dockutil or it doesn't find the plist.
sebastienkb commented 3 years ago

Hi @cnelson644

I need a solid 15 seconds PlistBuddy to not fail with Set: Entry, ":persistent-others:0:tile-data:displayas", Does Not Exist. Any idea on what takes so long?

sebastienkb commented 3 years ago

Also, the changes only occur if I do killall Dock afterwards, so there's 2 mandatory updates necessary (once for dockutil and once for PlistBuddy). If I skip either one, the dock doesn't get updated.

cnelson644 commented 3 years ago

@sebastienkb I think it has to do with the Dock not being fully loaded. I added this to the beginning of the loop to help with that. while ! /usr/libexec/PlistBuddy -c "Print :persistent-others:${counter}:tile-data:displayas" "/Users/${loggedInUser}/Library/Preferences/com.apple.dock.plist" sleep .5 done It will just loop until the Dock is ready.

cnelson644 commented 3 years ago

And yes you do have to add a killall Dock afterward. It's not the best solution but it gets the job done.

antifuchs commented 3 years ago

I was looking through the script's source code and found the problem: For adding directories, dockutil does a version check, and only checks the second part of the version, specifically for whether that version matches "4" (so, 10.4). MacOS Big Sur reports version number "11.4" - and so dockutil adds folders as if it was running on OS X Tiger, all the way back in 2005.

You can find a fix in #105 (validated on my macOS Big Sur install), and hopefully you find this as funny as I did, once I understood what's going on (: