-
Notifications
You must be signed in to change notification settings - Fork 4
/
AppIconInstaller.sh
41 lines (30 loc) · 1.31 KB
/
AppIconInstaller.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
#!/usr/bin/env bash
backupFolder="./backup/" # Change this path to choose your own backup location
echo This tool isn't able to change system app icons
echo Make sure app icons have the same name as the application you\'re trying to replace
echo You have to restart applications inside your dock to see updates
if [[ ! -d $backupFolder ]]; then
mkdir -p "$backupFolder"
fi
ls *.icns | while read newIcn; do
appName="${newIcn%.icns*}"
systemApp=""
if [[ -d "/System/Applications/"$appName".app/Contents" ]]; then
systemApp="/System"
elif [[ ! -d "/Applications/"$appName".app/Contents" ]]; then
echo Skipped $appName because icon not found
continue
fi
icn=`defaults read "$systemApp"/Applications/"$appName".app/Contents/info CFBundleIconFile`
if [[ ! $icn == *".icns" ]]; then
icn="$icn".icns
fi
if [[ ! -e "$backupFolder"/"$newIcn" ]]; then
sudo mv "$systemApp"/Applications/"$appName".app/Contents/Resources/"$icn" "$backupFolder"/"$newIcn"
else
echo "Backup icon for $appName already exists"
fi
sudo cp "$newIcn" "$systemApp"/Applications/"$appName".app/Contents/Resources/
sudo mv "$systemApp"/Applications/"$appName".app/Contents/Resources/"$newIcn" "$systemApp"/Applications/"$appName".app/Contents/Resources/"$icn"
sudo touch "$systemApp"/Applications/"$appName".app
done