forked from vinceliuice/Fluent-icon-theme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·199 lines (169 loc) · 9.08 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env bash
if [ ${UID} -eq 0 ]; then
DEST_DIR="/usr/share/icons"
else
DEST_DIR="${HOME}/.local/share/icons"
fi
readonly SRC_DIR=$(cd $(dirname $0) && pwd)
readonly COLOR_VARIANTS=("standard" "matrix" "ocean" "orange" "rose" "space" "sunrise" "fire")
readonly BRIGHT_VARIANTS=("" "dark")
readonly DEFAULT_NAME="Fluent"
usage() {
printf "%s\n" "Usage: $0 [OPTIONS...] [COLOR VARIANTS...]"
printf "\n%s\n" "OPTIONS:"
printf " %-25s%s\n" "-a, --all" "Install all color folder versions"
printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})"
printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${DEFAULT_NAME})"
printf " %-25s%s\n" "-r, --round" "Install rounded version"
printf " %-25s%s\n" "-b, --black" "Install black panel icon version"
printf " %-25s%s\n" "-h, --help" "Show this help"
printf "\n%s\n" "COLOR VARIANTS:"
printf " %-25s%s\n" "standard" "Standard color folder version"
printf " %-25s%s\n" "matrix" "matrix color folder version"
printf " %-25s%s\n" "ocean" "ocean color folder version"
printf " %-25s%s\n" "orange" "Orange color folder version"
printf " %-25s%s\n" "rose" "rose color folder version"
printf " %-25s%s\n" "space" "space color folder version"
printf " %-25s%s\n" "sunrise" "Sunrise color folder version"
printf " %-25s%s\n" "fire" "fire color folder version"
printf "\n %s\n" "By default, only the standard one is selected."
}
install_theme() {
# Appends a dash if the variables are not empty
if [[ "$1" != "standard" ]]; then
local -r colorprefix="-$1"
fi
local -r brightprefix="${2:+-$2}"
local -r THEME_NAME="${NAME}${colorprefix}${brightprefix}"
local -r THEME_DIR="${DEST_DIR}/${THEME_NAME}"
if [ -d "${THEME_DIR}" ]; then
rm -r "${THEME_DIR}"
fi
echo "Installing '${THEME_NAME}'..."
install -d "${THEME_DIR}"
install -m644 "${SRC_DIR}/src/index.theme" "${THEME_DIR}"
# Update the name in index.theme
sed -i "s/%NAME%/${THEME_NAME//-/ }/g" "${THEME_DIR}/index.theme"
if [ -z "${brightprefix}" ]; then
cp -r "${SRC_DIR}"/src/{16,22,24,32,64,256,scalable,symbolic} "${THEME_DIR}"
if [ "${round}" == 'true' ]; then
cp -r "${SRC_DIR}"/round/* "${THEME_DIR}"
fi
if [ "${black}" == 'true' ]; then
sed -i "s/#dedede/#363636/g" "${THEME_DIR}"/{16,22,24}/panel/*.svg
fi
cp -r "${SRC_DIR}"/links/{16,22,24,32,64,256,scalable,symbolic} "${THEME_DIR}"
if [ -n "${colorprefix}" ]; then
install -m644 "${SRC_DIR}"/colors/color${colorprefix}/places/*.svg "${THEME_DIR}/scalable/places"
install -m644 "${SRC_DIR}"/colors/color${colorprefix}/apps/*.svg "${THEME_DIR}/scalable/apps"
fi
else
local -r STD_THEME_DIR="${THEME_DIR%-dark}"
install -d "${THEME_DIR}"/{16,22,24,32,symbolic}
cp -r "${SRC_DIR}"/src/16/{actions,devices,places} "${THEME_DIR}/16"
cp -r "${SRC_DIR}"/src/22/{actions,devices,places} "${THEME_DIR}/22"
cp -r "${SRC_DIR}"/src/24/{actions,devices,places} "${THEME_DIR}/24"
cp -r "${SRC_DIR}"/src/32/actions "${THEME_DIR}/32"
cp -r "${SRC_DIR}"/src/symbolic/* "${THEME_DIR}/symbolic"
if [ "${round}" == 'true' ]; then
cp -r "${SRC_DIR}"/round/symbolic/* "${THEME_DIR}/symbolic"
fi
if [ "${black}" == 'true' ]; then
cp -r "${SRC_DIR}"/src/16/panel "${THEME_DIR}/16"
cp -r "${SRC_DIR}"/src/22/panel "${THEME_DIR}/22"
cp -r "${SRC_DIR}"/src/24/panel "${THEME_DIR}/24"
fi
# Change icon color for dark theme
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{16,22,24,32}/actions/*.svg
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/{16,22,24}/{places,devices}/*.svg
sed -i "s/#363636/#dedede/g" "${THEME_DIR}"/symbolic/{actions,apps,categories,devices,emblems,emotes,mimetypes,places,status}/*.svg
cp -r "${SRC_DIR}"/links/16/{actions,devices,places} "${THEME_DIR}/16"
cp -r "${SRC_DIR}"/links/22/{actions,devices,places} "${THEME_DIR}/22"
cp -r "${SRC_DIR}"/links/24/{actions,devices,places} "${THEME_DIR}/24"
cp -r "${SRC_DIR}"/links/32/actions "${THEME_DIR}/32"
cp -r "${SRC_DIR}"/links/symbolic/* "${THEME_DIR}/symbolic"
if [ "${black}" == 'true' ]; then
cp -r "${SRC_DIR}"/links/16/panel "${THEME_DIR}/16"
cp -r "${SRC_DIR}"/links/22/panel "${THEME_DIR}/22"
cp -r "${SRC_DIR}"/links/24/panel "${THEME_DIR}/24"
fi
# Link the common icons
ln -sr "${STD_THEME_DIR}/scalable" "${THEME_DIR}/scalable"
ln -sr "${STD_THEME_DIR}/16/mimetypes" "${THEME_DIR}/16/mimetypes"
ln -sr "${STD_THEME_DIR}/16/status" "${THEME_DIR}/16/status"
ln -sr "${STD_THEME_DIR}/22/emblems" "${THEME_DIR}/22/emblems"
ln -sr "${STD_THEME_DIR}/22/mimetypes" "${THEME_DIR}/22/mimetypes"
ln -sr "${STD_THEME_DIR}/24/animations" "${THEME_DIR}/24/animations"
ln -sr "${STD_THEME_DIR}/32/categories" "${THEME_DIR}/32/categories"
ln -sr "${STD_THEME_DIR}/32/status" "${THEME_DIR}/32/status"
ln -sr "${STD_THEME_DIR}/64" "${THEME_DIR}/64"
ln -sr "${STD_THEME_DIR}/256" "${THEME_DIR}/256"
if [ "${black}" != 'true' ]; then
ln -sr "${STD_THEME_DIR}/16/panel" "${THEME_DIR}/16/panel"
ln -sr "${STD_THEME_DIR}/22/panel" "${THEME_DIR}/22/panel"
ln -sr "${STD_THEME_DIR}/24/panel" "${THEME_DIR}/24/panel"
fi
fi
ln -sr "${THEME_DIR}/16" "${THEME_DIR}/16@2x"
ln -sr "${THEME_DIR}/22" "${THEME_DIR}/22@2x"
ln -sr "${THEME_DIR}/24" "${THEME_DIR}/24@2x"
ln -sr "${THEME_DIR}/32" "${THEME_DIR}/32@2x"
ln -sr "${THEME_DIR}/64" "${THEME_DIR}/64@2x"
ln -sr "${THEME_DIR}/256" "${THEME_DIR}/256@2x"
ln -sr "${THEME_DIR}/scalable" "${THEME_DIR}/scalable@2x"
ln -sr "${THEME_DIR}/16" "${THEME_DIR}/16@3x"
ln -sr "${THEME_DIR}/22" "${THEME_DIR}/22@3x"
ln -sr "${THEME_DIR}/24" "${THEME_DIR}/24@3x"
ln -sr "${THEME_DIR}/32" "${THEME_DIR}/32@3x"
ln -sr "${THEME_DIR}/64" "${THEME_DIR}/64@3x"
ln -sr "${THEME_DIR}/256" "${THEME_DIR}/256@3x"
ln -sr "${THEME_DIR}/scalable" "${THEME_DIR}/scalable@3x"
gtk-update-icon-cache "${THEME_DIR}"
}
while [ $# -gt 0 ]; do
case "${1}" in
-a|--all)
colors=("${COLOR_VARIANTS[@]}")
;;
-d|--dest)
DEST_DIR="${2}"
shift
;;
-n|--name)
NAME="${2}"
shift
;;
-r|--round)
round="true"
echo "Installing 'Round' version..."
shift
;;
-b|--black)
black="true"
echo "Installing 'Black' version..."
shift
;;
-h|--help)
usage
exit 0
;;
*)
# If the argument is a color variant, append it to the colors to be installed
if [[ " ${COLOR_VARIANTS[*]} " = *" ${1} "* ]] && [[ "${colors[*]}" != *${1}* ]]; then
colors+=("${1}")
else
echo "ERROR: Unrecognized installation option '${1}'."
echo "Try '${0} --help' for more information."
exit 1
fi
esac
shift
done
# Default name is 'Fluent'
: "${NAME:="${DEFAULT_NAME}"}"
# By default, only the standard color variant is selected
for color in "${colors[@]:-standard}"; do
for bright in "${BRIGHT_VARIANTS[@]}"; do
install_theme "${color}" "${bright}"
done
done