forked from tinalatif/flat.icns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
64 lines (54 loc) · 1.14 KB
/
install.sh
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
54
55
56
57
58
59
60
61
62
63
64
# exit on errors
set -o errexit
set -o nounset
# constants
URL='https://github.com/tinalatif/flat.icns/archive/1.0.zip'
ZIP='/tmp/tinalatif-zip'
DIR='/tmp/tinalatif-icns'
# replace_icon ICNS APP
replace_icon() {
file="$1"
dest="$2"
icon=/tmp/$(basename "$file")
rsrc=/tmp/icon.rsrc
# generate rsrc
cp "$file" "$icon"
sips -i "$icon" > /dev/null
DeRez -only icns "$icon" > "$rsrc"
# set icon
Rez -append $rsrc -o "$dest"$'/Icon\r'
SetFile -a C "$dest"
SetFile -a V "$dest"$'/Icon\r'
}
# replace_app_icon ICNS
replace_app_icon() {
icon="$1"
name=$(basename "$icon" .icns)
app="/Applications/$name.app"
if [ -d "$app" ]; then
echo " * $name"
replace_icon "$icon" "$app"
fi
}
echo
echo ' Thanks for installing flat.icns!'
# need root
if [ $EUID -ne 0 ]; then
echo
echo ' ERROR: script needs root to change app icons.'
echo ' FIX: run with sudo or su.'
echo
exit 1
fi
echo
echo ' Downloading icon files'
curl -L --progress-bar -o $ZIP $URL
unzip -qq -o -j $ZIP -d $DIR
echo
echo ' Replacing app icons'
for file in $DIR/*.icns; do
replace_app_icon "$file"
done
echo
echo ' All done! Restart your computer.'
echo