On 9/22/2014 9:28 AM, Tiemo Hollmann TB wrote: > Hi, > > can somebody give me a hint on how to add an alias of a program by script > (shell) to the dock? > >
The command below should do it for you. NOTE: The 2 filters are to handle differences between versions of OSX - tested from Leopard to Mavericks. It presents a dialog to alert if an identical alias is already on the dock. Comment out the answer if you don't want that. command CreateOSXDockAlias pDockItem -- pDockItem is the fill path and name of the app local tPreserveLockScreen local tDockItem, tInstalledDockItems, tInstallDockItem put the lockScreen into tPreserveLockScreen if not tPreserveLockScreen then lock screen put pDockItem into tDockItemFilter1 put pDockItem into tDockItemFilter2 replace space with "%20" in tDockItemFilter2 -- effectively Percent Encode string put shell("defaults read com.apple.dock persistent-apps") into tInstalledDockItems put tInstalledDockItems into tTestFormat1 -- to use without %20 replacement for space put tInstalledDockItems into tTestFormat2 -- to use with %20 replacement for space filter tTestFormat1 with ("*"&tDockItemFilter1&"*") -- filter to just this version of the app filter tTestFormat2 with ("*"&tDockItemFilter2&"*") -- filter to just this version of the app if (tTestFormat1 is empty) AND (tTestFormat2 is empty) then -- not already in dock put "defaults write com.apple.dock persistent-apps -array-add " into tInstallDockItem put "'<dict><key>tile-data</key><dict><key>file-data</key><dict>" after tInstallDockItem put "<key>_CFURLString</key><string>"&pDockItem&"</string>" after tInstallDockItem put "<key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'" after tInstallDockItem put shell(tInstallDockItem) into tResult -- install into the Dock put shell("killall -HUP Dock") into tResult -- restart Dock to show new item else answer information pDockItem && "is already installed on the Dock" with "OK" end if if not tPreserveLockScreen then unlock screen end CreateOSXDockAlias _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode