|
Quick Links
Calendar
Categories
Archives
XML/RSS Feed
Links
Radmind.org
Secret World of Nerds Radmind Webmin Module MacEnterprise.org afp548.com University of Utah's Mac OS Documentation Mike Bombich's OS X Software and Tips
Statistics
Total entries in this blog:
Total entries in this category: Published On: Jan 02, 2005 09:30 AM |
Updating Dock iconsIn one-to-one deployments, you may not have direct
control of a user's Dock - especially if you do not use Macintosh Manager
becuase you are using a non-Apple directory. When you update applications on a
user's machine, this sometimes breaks Dock items. We faced this when updating
machines from Office v.X to Office 2004. I wrote a script that ran at login that
changed any existing Office v.X Dock icons into their corresponding Office 2004
icons.
The script is posted here in a
quick tip I submitted to MacEnterprise.org. It's meant to be run by my
LoginLauncher app (current
version) (older
version). I repost the script here as
well:
#!/usr/bin/perl # This script edits com.apple.dock.plist # to remove Office X entries and replace them with # Office 2004 entries. # # # by Greg Neagle Jul 2004 $homedir = $ENV{'HOME'}; # is Office 2004 installed? if (-d "/Applications/Microsoft Office 2004") { # has this script done its thing? if (!(-e "$homedir/Library/Preferences/com.apple.dock.plist.officex")) { open DOCKPREFS, "$homedir/Library/Preferences/com.apple.dock.plist" or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist"); open DOCKOUTPUT, ">$homedir/Library/Preferences/com.apple.dock.plist.new" or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist.new for output"); until (eof DOCKPREFS) { $text = readline(DOCKPREFS); print DOCKOUTPUT "$text"; if ($text =~ "file-data") { $dictBlock = ""; $officeAppFound = 0; while(!($text =~ "")) { $text = readline(DOCKPREFS); if ($text =~ "/Applications/Microsoft Office X/") { # replace the path $text =~ s/Microsoft Office X/Microsoft Office 2004/; $officeAppFound = 1; } $dictBlock = $dictBlock . $text; } if ($officeAppFound) { # get rid of the _CFURLAliasData block $dictBlock =~ s|_CFURLAliasData.*||s } print DOCKOUTPUT "$dictBlock"; } } close (DOCKOUTPUT); close (DOCKPREFS); #rename our files `mv $homedir/Library/Preferences/com.apple.dock.plist $homedir/Library/Preferences/com.apple.dock.plist.officex` ; `mv $homedir/Library/Preferences/com.apple.dock.plist.new $homedir/Library/Preferences/com.apple.dock.plist` ; # restart the Dock `killall Dock`; } } #END The basic concepts here could be used to update other icons. The key points are that the path to the item is modified, and that the "CFURLAliasData" is removed. This needs to be removed because it is an alias that points to the old file item. The first time the user clicks on the icon after the update, this data is regenerated based on the pathname. Posted: Sun - January 2, 2005 at 09:15 AM |
||||||||||||||