Add Terminal to dock persistent-apps with default write with foreign language macOS
Asked Answered
W

2

5

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.

Wartime answered 6/1, 2020 at 15:0 Comment(0)
N
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!

Nonresistant answered 8/1, 2020 at 0:4 Comment(0)
B
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
Berthoud answered 4/5, 2022 at 0:48 Comment(1)
Nice to highlight the fact that Applications can live in either /System/Applications or /Applications.Hilbert

© 2022 - 2024 — McMap. All rights reserved.