Dynamic Dock icon

Hi,
it is fairly simple to switch an Applescript-Application icon, but what if i want to change an application icon in the dock?
How to achieve that change ?

-rewriting the dock’s plist?
-using Shane’s AsObjC Runner ?

Assuming it’s not code-signed, open the package, delete applet.icns from /Contents/Resources/, add your own .icns file, then open /Contents/Info.plist and change the entry for CFBundleIconFile to match the new file’s name (minus extension). A Web search will find you lots of ways to build an .icns file.

Hi Shane,
there is a misunderstanding.
i created an Applescript App who changes its icon in because of some events. My app works in the “Finder”- the icon changes, but the same does not apply for the icon in my Dock. Here we go.

Sorry, I don’t understand what you’re saying.

I think what he wants to do is have his running AppleScript app select among its internal icons and display the chosen one in the dock.

OK, that can be done using an ASObjC-based library:

use framework "Foundation"
use framework "AppKit"

on changeDockImageTo:posixPathToImage
	set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:posixPathToImage
	set theImageView to current application's NSImageView's alloc()'s initWithFrame:{origin:{x:0, y:0}, |size|:{width:64, height:64}}
	set theDockTile to current application's NSApp's dockTile()
	theDockTile's setContentView:theImageView
	theImageView's setImage:theImage
	theDockTile's display()
end changeDockImageTo:

Yes, yes, that is what i looked for ! :slight_smile:

However, the code does not compile and my copy of ASobjC is running. (Lion v4)

That script requires Mavericks; even with ASObjC Runner, it won’t run under earlier versions.

Actually, I dont think to switch to another Os. Apples politics continue to change in a way i dont like, now more than ever without Steve.
Is there another, practicable way to go to change dock icons?

Not that I know of.

Do it in real Objective-C. :wink: