-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtag_icons.sh
More file actions
53 lines (46 loc) · 1.71 KB
/
tag_icons.sh
File metadata and controls
53 lines (46 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Overlay the build version and the git hash on the app icon
#
# Inspired by @merowing and @bejo script
# who were inspired initially by Evan Doll's talk
#
# http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/#.VCg9li5_v6A
# https://github.com/bejo/XcodeIconTagger/blob/master/tagIcons.sh
# script subcommands
mode=$1
tagMode="tag"
cleanupMode="cleanup"
function processIcon() {
export PATH=$PATH:/usr/local/bin:/opt/boxen/homebrew/bin/
icon_path=$1
width=`identify -format %w ${icon_path}`
height=`identify -format %h ${icon_path}`
#create a resized watermark image which will be placed above the original image
convert $(dirname $0)/watermark.png -resize ${width}x${height} ${icon_path}.watermark
#apply it on top of the original image
composite -gravity center -quality 100 ${icon_path}.watermark ${icon_path} ${icon_path}
#remove the resized image as it not needed.
rm ${icon_path}.watermark
echo "Icon '$icon_path' updated"
}
# retrieve the icon list from the assets catalogue
iconsDirectory=`cd $2 && pwd`
if [ $(echo "${iconsDirectory}" | grep -E "\.appiconset$") ]; then
icons=(`grep 'filename' "${iconsDirectory}/Contents.json" | cut -f2 -d: | tr -d ',' | tr -d '\n' | tr -d '"'`)
else
icons=(`/usr/libexec/PlistBuddy -c "Print CFBundleIconFiles" "${INFOPLIST_FILE}" | grep png | tr -d '\n'`)
fi
iconsCount=${#icons[*]}
for (( i=0; i<iconsCount; i++ ))
do
icon="$iconsDirectory/${icons[$i]}"
if [ -f $icon ]; then
if [ $mode == $tagMode ]; then
# tag it
processIcon $icon
else
echo " ! Unknown mode `$mode`"
fi
else
echo " ! No icon for path `$icon`"
fi
done