Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing App Icon

I'm trying to make an application that generates and app (with Applescript), and so far I've gone as far as generating the normally functioning app by using the (do shell script "osacompile...") command. Now, all I need is a string that will automatically also change the icon of the generated application, as I would like my own icon to be the newly generated application's icon rather than the default Applet icon.

What are some ways to approach this?

Thanks a ton.

Eric

like image 790
user3541125 Avatar asked May 15 '26 02:05

user3541125


2 Answers

Assuming you've created an app bundle, e.g. via:

osascript -o Foo.app foo.applescript

Then you can either simply overwrite the existing icon file:

cp -f myicon.icns Foo.app/Contents/Resources/applet.icns

or copy over a new icon file, and update the Info.plist:

rm Foo.app/Contents/Resources/applet.icns
cp myicon.icns Foo.app/Contents/Resources/
plutil -replace CFBundleIconFile -string myicon.icns Foo.app/Contents/Info.plist
like image 144
Simon Byrne Avatar answered May 17 '26 09:05

Simon Byrne


Icons of applications are shown based on the info.plist inside the application bundle. There is a key named CFBundleIconFile whose value is the name of the icon file in the resource folder. The simplest way is that an AppleScript saved as application has the icon file applet.icns and replace it afterwards. Or you can add your own icon file to the resource folder, remove the icns file created by osacompile and change the info.plist file inside the bundle. Because you have no example code, which is normally required on StackOverflow, I can't help you further than this.

like image 28
dj bazzie wazzie Avatar answered May 17 '26 10:05

dj bazzie wazzie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!