Applying new app icons for core apps using AppleScript

Discussion in 'Mac Programming' started by johndoe123abc, Aug 23, 2014.

  1. johndoe123abc macrumors member

    Joined:
    Jul 10, 2012
    #1
    Hi,

    I'm trying to use a shell script to change the default icons of native apps e.g. iTunes, Mail, Safari etc.

    I've been trying to use the seticon command line utility that is part of osxutils, mostly because I don't want to have to install developer tools / may encounter a machine without them.

    The current code is as follows:

    Code:
    tell application "Finder"
    	
    	set icon_path to "/Volumes/Data/Extras/Software/Icons/"
    	do shell script icon_path & "util/seticon -d " & icon_path & "icon.icns" & " /Applications/Stickies.app"
    	
    end tell
    
    The app runs without error, and returns "" as a result, however the icon remains the unchanged. Does anyone know how to fix this, or have another programatic solution that I can use on a non-dev machine?

    Thanks!
     
  2. kryten2, Aug 23, 2014
    Last edited: Aug 23, 2014

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2

    There's no need for a tell application Finder block and you need administrator privileges to change the icon for applications in the Applications folder e.g.

    Code:
    set icon_path to "/Volumes/Data/Extras/Software/Icons/"
    do shell script icon_path & "util/seticon -d " & icon_path & "icon.icns" & " /Applications/Stickies.app" with administrator privileges
    Put the seticon and icns file in the Resources folder of your app. Look at the path to resource section here

    Example :

    Code:
    set icon_path to path to resource "Outlook.icns"
    set seticon_path to path to resource "seticon"
    do shell script quoted form of POSIX path of seticon_path & " -d " & quoted form of POSIX path of icon_path & " /Users/kryten/Applications/Stickies.app" --with administrator privileges
     

    Attached Files:

  3. johndoe123abc, Aug 24, 2014
    Last edited: Aug 24, 2014

    johndoe123abc thread starter macrumors member

    Joined:
    Jul 10, 2012
    #3
    Many thanks kryten2, the administrator privileges bit solved the problem!
     

Share This Page