

Then with macOS Mojave there is recent-apps which shows between the two aforementioned sections (by key name) on the Dock. There are also additional items that can show on the Dock, the first being the default persistent-others, which has the Downloads stack and other items you've added to that section. Note: In your OP you stated "I'm trying to remove (all) items from the dock." and the code you've presented only focuses on the apps stored under the persistent-apps key. If for some reason you need to do this with AppleScript, you can use the do shell script command to run these shell commands. If later you want to restore the backup, use the following compound command: cd ~/Library/Preferences rm cp -a .bak killall Dock Now to remove the persistent apps, use the following compound command: defaults delete persistent-apps killall Dock In Terminal, do the following to first backup the target file: Here is a much more straight forwards approach to removing the persistent apps on the Dock found in the persistent-apps key of the file: Set end of dockAppsList to |file-label| of |tile-data| of thisRecordĪs an alternative. Repeat with thisRecord in persistentAppsList Set persistentAppsList to |persistent-apps| of pListItems
Set plistContents to contents of property list file plistpath

set plistpath to (path to preferences folder as text) & "" I think I'm misunderstanding how to convert "thisRecord" into something I can reference within system events. I would guess that referencing the current item of the list inside the loop would be done with "thisRecord". What I'd like to do is tweak the above code to operate inside of a loop.

This stack overflow question seems to cover how to get the list. Tell UI element "Launchpad" of list 1 of process "Dock"Ĭlick menu item "Remove from Dock" of menu 1īut I'd like to pull the list of current items and iterate over them. I can remove them by name like so: tell application "System Events" I'm trying to remove (all) items from the dock.
