4

Adding Google to the dock works like this:

    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

But adding Terminal to the dock does not work with these:

    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Utilities/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

    defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Lisäohjelmat/Pääte</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

I would love to keep my computers language as Finnish, while still being able to have a customised dock through my Dotfiles. And this same issue is persistent with the MacOS default apps, such as terminal and calendar etc.

2 Answers 2

6

I believe I have a similar problem to you, however, I do not think it‘s a localisation issue. Digging deeper it looks to me that these apps aren‘t really where they seem.

Try going to /Applications/Lisäohjelmat in the Finder. Now open up Terminal and do ls /Applications/Lisäohjelmat. Notice a difference? On my English language version of macOS, when I ls the /Applications/Utilities directory I see an empty folder!

As far as I can gather most of the System applications now reside in /System/Applications/ and I would assume that perhaps this is the case for you too.

Bringing it all together, my first-run Dock setup looks like (adjust for your needs after confirming where the applications are):

#!/bin/sh

set -e

__dock_item() {
    printf '%s%s%s%s%s' \
           '<dict><key>tile-data</key><dict><key>file-data</key><dict>' \
           '<key>_CFURLString</key><string>' \
           "$1" \
           '</string><key>_CFURLStringType</key><integer>0</integer>' \
           '</dict></dict></dict>'
}

printf '%s' 'Setting up Dock icons...'
defaults write com.apple.dock \
               persistent-apps -array "$(__dock_item /Applications/Safari.app)" \
                                      "$(__dock_item /System/Applications/Utilities/Terminal.app)"
killall Dock
printf '%s\n' ' done.'

Note: I have used -array instead of -array-add which just completely clears the array and sets it to what I give.

Hope that helps and good luck!

1

For me, I do something like this:

# clear items
defaults write com.apple.dock persistent-apps -array

for dockItem in {/System/Applications/{"Mail","Notes","System Preferences","App Store","Preview"},/Applications/{"iTerm","Visual Studio Code","Brave Browser"}}.app; do
  defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>'$dockItem'</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
done
1
  • Nice to highlight the fact that Applications can live in either /System/Applications or /Applications.
    – thoroc
    Commented Jul 3 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.