Mac OS application shortcut on the Dock

Answered

Comments

2 comments

  • Avatar
    wojciechka

    You can use the defaults command to add an application to dock.

    You also need to restart the Dock application to refresh changes.

    For example:

    <runProgram> <program>defaults</program> <programArguments>write com.apple.dock persistent-apps -array-add ' &lt;dict&gt; &lt;key&gt;tile-data&lt;/key&gt; &lt;dict&gt; &lt;key&gt;file-data&lt;/key&gt; &lt;dict&gt; &lt;key&gt;_CFURLString&lt;/key&gt; &lt;string&gt;${installdir}/your.app&lt;/string&gt; &lt;key&gt;_CFURLStringType&lt;/key&gt; &lt;integer&gt;0&lt;/integer&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/dict&gt;' </programArguments> </runProgram> <runProgram> <program>killall</program> <programArguments>-HUP Dock</programArguments> </runProgram>

    The first command registers the application in the dock. You will need to change the path from ${installdir}/your.app to actual path to the .app bundle. The second command restarts the Dock program.

    Also, please note that if your installer is running as administrator (i.e. by setting <requireInstallationByRootUser> set to 1), you need to run su command to run the defaults command as appropriate user.

  • Avatar
    Codename K

    To remove the Dock icon you have to use a AppleScript. You need to run this at uninstallation. Replace the 'dockappname' with the dock icon name,

    try
        tell application "System Events"
            set dockPlistFile to property list file "~/Library/Preferences/com.apple.dock.plist"
            tell dockPlistFile
                tell property list item "persistent-apps"
                    set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "dockappname")
                    set its value to appTileItems
                end tell
            end tell
        end tell
        tell application "Dock" to quit
    end try
    

Please sign in to leave a comment.