-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·69 lines (50 loc) · 1.38 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
65
66
67
68
69
#!/usr/bin/env bash
# Exit on errors
set -o errexit
set -o nounset
# Constants
URL=https://raw.githubusercontent.com/Greenek/polymail.icns/master/Polymail.icns
# Check if operating system is supported
if [[ $OSTYPE != "darwin"* ]]; then
echo "This script requires OSX system to run."
exit 1
fi
# Check if Polymail.app is installed
: ${POLYMAIL_PATH:="/Applications/Polymail.app"}
if [ ! -d "$POLYMAIL_PATH" ]; then
echo "Polymail.app not found."
exit 1
fi
# Initialize temporary files paths
TMPICNS=$TMPDIR"Polymail.icns"
TMPRSRC=$TMPDIR"icon.rsrc"
if [ $# -eq 0 ]; then
# Download icon file if path has not been passed in argument
curl -L -o $TMPICNS $URL
else
cp -f $1 $TMPICNS
fi
# Add icon to image file
sips -i $TMPICNS >> /dev/null
# Take icon and put into a rsrc file
DeRez -only icns $TMPICNS > $TMPRSRC
# Apply the rsrc file
SetFile -a C $POLYMAIL_PATH
# Remove old resource
rm -f $POLYMAIL_PATH/Icon?
# Append icon resource
Rez $TMPRSRC -o $POLYMAIL_PATH/$'Icon\r'
SetFile -a V $POLYMAIL_PATH/Icon?
# Clean
rm $TMPRSRC $TMPICNS
# Success output
cat << EOF
New icon for Polymail.app has been successfully installed.
TO COMPLETE INSTALLATION:
1) Restart application
or
2) Clear system icon cache
sudo find /private/var/folders/ -name com.apple.dock.iconcache -exec rm {} \;
sudo find /private/var/folders -name com.apple.iconservices -exec rm -rf {} \;
killall Dock
EOF