forked from tinalatif/flat.icns
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·88 lines (73 loc) · 1.97 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# constants
BASEDIR=$(dirname "$0")
ICNS_DIR="${BASEDIR}/icns"
ICNS_FILES="${ICNS_DIR}/*.icns"
FILEICON_DIR="${BASEDIR}/libs/fileicon.sh"
ICON_PATH=(
"/Applications"
"/Applications/Utilities"
"$HOME/Applications"
"/Applications/JetBrains Toolbox"
"$HOME/Applications/JetBrains Toolbox"
)
# Colors
Color_Off='\033[0m' # Text Reset
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
set_icons() {
request_sudo
echo "Installing icons..."
for icon in $ICNS_FILES; do
basename=${icon##*/}
basename=${basename%.icns}
for path in ${ICON_PATH[@]}; do
if [ -d "${path}/${basename}.app" ]; then
echo "Setting icon for ${Red}${basename}${Color_Off} at ${path}/${basename}.app"
sudo bash ${FILEICON_DIR} set "${path}/${basename}.app" "${ICNS_DIR}/${basename}.icns"
fi
done
done
}
clear_icons() {
request_sudo
echo "Restoring icons..."
for icon in $ICNS_FILES; do
basename=${icon##*/}
basename=${basename%.icns}
for path in ${ICON_PATH}; do
if [ -d "${path}/${basename}.app" ]; then
echo "Restoring original icon for ${Red}${basename}${Color_Off} at ${path}/${basename}.app"
sudo bash ${FILEICON_DIR} rm "${path}/${basename}.app"
fi
done
done
}
request_sudo() {
if [[ $EUID > 0 ]]; then
echo "You may be asked to enter your password, this is required to change some system icons"
sudo echo ""
fi
}
echo $#
if [ $# -ge 1 ]; then
case $1 in
"help")
echo "Usage: $0 [option]"
echo "\t$0 install - to install icons"
echo "\t$0 restore - to restore original icons"
echo "\t$0 help - show this help"
;;
"install") set_icons ;;
"restore") clear_icons ;;
*) echo "For help write: $0 help" ;;
esac
else
set_icons
fi