3

I like to use custom icons for a few apps. However, of course, when an app updates the icon is reset. I'd like to be able to run a script to instantly update all of my custom app icons automatically.

At present, I right click on an app and select get info. Then, I can drag an .icns file on to the original icon at the top of this window. Relaunch the dock, and done! Much like this tutorial.

Does anyone know if there's a terminal command to achieve the same thing? I've seen variations that dive into an app's resources folder and change the .icns file there, but this is a different process, and I haven't had much look with this.

Any ideas?

0

I have a folder called “App Icons” in my Dropbox. Just inside I have a shell script called install.sh, and next to that I have folders for each app I want custom icons for. Currently that’s Atom and Mattermost.

Inside each directory I have atom.icns and Mattermost.icns, respectively.

To get both apps updated I run this script:

#!/usr/bin/env bash

set -euf -o pipefail
umask 077
has_copied=0

for atom in Atom "Atom Beta"; do
    path="/Applications/${atom}.app"
    [ -d "${path}" ] && \
    cp ./Atom/atom.icns "${path}/Contents/Resources/atom.icns" && \
    touch "${path}" && \
    has_copied=1
done

for mattermost in Mattermost; do
    path="/Applications/${mattermost}.app"
    [ -d "${path}" ] && \
    cp ./Mattermost/Mattermost.icns "${path}/Contents/Resources/Mattermost.icns" && \
    touch "${path}" && \
    has_copied=2
done

[ ${has_copied} = "2" ] && killall Dock

Atom usually updates immediately with the [ ${has_copied} = "2" ] && killall Dock line. Mattermost does not, but I’m guessing that’s a case-by-case basis. I suspect there is a much smarter way to loop through all available icons and update their respective apps, but I’m no bash maestro, so I kept it simple.

In order to run this automatically you might use Automator, or event better, follow the instructions in this SO answer: https://stackoverflow.com/a/13372744/347884

If you choose the second route, make sure your shell script is executable:

chmod a+x /path/to/script.sh

Have fun!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.