-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
308 lines (270 loc) · 9.47 KB
/
setup.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/bin/sh
# -------------------------------------------------
# Installation script for the hi-theme by SLywnow
# -------------------------------------------------
clear
INSTALLER_DIR="$(dirname $(readlink -f $0))"
REFIND_DIR="$1"
DEST_DIR="${REFIND_DIR}/themes/hi-theme"
echo "Wlcome to hi-themes for rEFInd Installation script!"
# Exit when an error
set -e
trap 'echo "close setup.sh"' EXIT
if [ ! -d "$1" ]; then
echo "ERROR: Give a path to the rEFInd directory"
exit 2
fi
# Check
if [ -d "$DEST_DIR" ]; then
echo "hi-theme is already installed, would you like to resetup it (old hi-theme will be deleted) [Y/n]?"
read -p "" answer
if [ "$answer" = "Y" -o "$answer" = "y" ]; then
rm -r "$DEST_DIR"
else
echo "Installation cancelled"
exit 0
fi
fi
#Presets
echo "Do you want use preset or run custom theme setup?"
echo "0 - Custom setup, 1 - Dark preset, 2 - Light preset, 3 - Red preset, 4 - Green preset, 5 - Blue preset, 6 - Purple preset"
read -p "№ " instaltype
#Presets
if [ $instaltype = 1 ]; then
echo "Dark selected, generating theme..."
slcurbgs=1
slcuricons=2
slcurseltpe=1
slcurselcol=2
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
elif [ $instaltype = 2 ]; then
echo "Light selected, generating theme..."
slcurbgs=2
slcuricons=1
slcurseltpe=2
slcurselcol=1
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
elif [ $instaltype = 3 ]; then
echo "Red selected, generating theme..."
slcurbgs=3
slcuricons=3
slcurseltpe=3
slcurselcol=3
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
elif [ $instaltype = 4 ]; then
echo "Green selected, generating theme..."
slcurbgs=4
slcuricons=4
slcurseltpe=4
slcurselcol=4
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
elif [ $instaltype = 5 ]; then
echo "Blue selected, generating theme..."
slcurbgs=5
slcuricons=5
slcurseltpe=4
slcurselcol=5
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
elif [ $instaltype = 6 ]; then
echo "Purple selected, generating theme..."
slcurbgs=6
slcuricons=6
slcurseltpe=2
slcurselcol=6
slconfshd=1
slconfrb=0
slconfext=0
deletefiles=1
fi
#Custom
if [ $instaltype = 0 ]; then
echo "Custom selected, waiting the options..."
echo "----Files----"
echo "What background do you want?"
echo "1 - Dark (Spruce forest), 2 - Light (Forest), 3 - Red (Bloody), 4 - Green (Vines), 5 - Blue (Rain in ocean), 6 - Purple (Retro)"
read -p "№ " bgs
echo "--------"
echo "What icons do you want?"
echo "1 - Dark icons, 2 - Light icons, 3 - Red icons, 4 - Green icons, 5 - Blue icons, 6 - Purple icons"
read -p "№ " icn
echo "--------"
echo "What type of selectors do you want?"
echo "1 - Neon frame, 2 - Line and point, 3 - Background frames, 4 - Background light"
read -p "№ " seltpe
echo "--------"
echo "What color of selectors do you want?"
echo "1 - Dark, 2 - Light, 3 - Red, 4 - Green, 5 - Blue, 6 - Purple"
read -p "№ " selcl
echo "----Congig----"mkdir -p $DEST_DIR
echo "Do you want shutdown button? [y/n]"
read -p "" shd
if [ "$shd" = "Y" -o "$shd" = "y" ]; then
slconfshd=1
fi
echo "----Congig----"
echo "Do you want reboot button? [y/n]"
read -p "" rb
if [ "$rb" = "Y" -o "$rb" = "y" ]; then
slconfrb=1
fi
echo "----Congig----"
echo "Do you want exit button? [y/n]"
read -p "" ext
if [ "$ext" = "Y" -o "$ext" = "y" ]; then
slconfext=1
fi
echo "----Final----"
echo "Do you want clear temp theme files (default yes)? [y/n]"
read -p "" ext
if [ "$ext" = "Y" -o "$ext" = "y" ]; then
deletefiles=1
fi
slcurbgs=$bgs
slcuricons=$icn
slcurseltpe=$seltpe
slcurselcol=$selcl
echo "Options accepted, generating theme..."
fi
#Setuptheme
rm -Rf $INSTALLER_DIR/hi-theme
mkdir -p $INSTALLER_DIR/hi-theme
if [ $slcurbgs = 1 ]; then
cp $INSTALLER_DIR/main/bgs/1background.png $INSTALLER_DIR/hi-theme/background.png
elif [ $slcurbgs = 2 ]; then
cp $INSTALLER_DIR/main/bgs/2background.png $INSTALLER_DIR/hi-theme/background.png
elif [ $slcurbgs = 3 ]; then
cp $INSTALLER_DIR/main/bgs/3background.png $INSTALLER_DIR/hi-theme/background.png
elif [ $slcurbgs = 4 ]; then
cp $INSTALLER_DIR/main/bgs/4background.png $INSTALLER_DIR/hi-theme/background.png
elif [ $slcurbgs = 5 ]; then
cp $INSTALLER_DIR/main/bgs/5background.png $INSTALLER_DIR/hi-theme/background.png
elif [ $slcurbgs = 6 ]; then
cp $INSTALLER_DIR/main/bgs/6background.png $INSTALLER_DIR/hi-theme/background.png
else
echo "ERROR: Setup failed on getting background, if you select right numbers or select preset, contact with me in github"
exit 2
fi
if [ $slcuricons = 1 ]; then
cp -r $INSTALLER_DIR/main/icons/1dark $INSTALLER_DIR/hi-theme/icons
elif [ $slcuricons = 2 ]; then
cp -r $INSTALLER_DIR/main/icons/2light $INSTALLER_DIR/hi-theme/icons
elif [ $slcuricons = 3 ]; then
cp -r $INSTALLER_DIR/main/icons/3red $INSTALLER_DIR/hi-theme/icons
elif [ $slcuricons = 4 ]; then
cp -r $INSTALLER_DIR/main/icons/4green $INSTALLER_DIR/hi-theme/icons
elif [ $slcuricons = 5 ]; then
cp -r $INSTALLER_DIR/main/icons/5blue $INSTALLER_DIR/hi-theme/icons
elif [ $slcuricons = 6 ]; then
cp -r $INSTALLER_DIR/main/icons/6purple $INSTALLER_DIR/hi-theme/icons
else
echo "ERROR: Setup failed on getting icons, if you select right numbers or select preset, contact with me in github"
exit 2
fi
if [ $slcurseltpe = 1 ]; then
selpath="1neon-frame"
elif [ $slcurseltpe = 2 ]; then
selpath="2line"
elif [ $slcurseltpe = 3 ]; then
selpath="3frame"
elif [ $slcurseltpe = 4 ]; then
selpath="4background-light"
else
echo "ERROR: Setup failed on setting selector's type, if you select right numbers or select preset, contact with me in github"
exit 2
fi
if [ $slcurselcol = 1 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/dark/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/dark/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
elif [ $slcurselcol = 2 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/light/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/light/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
elif [ $slcurselcol = 3 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/red/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/red/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
elif [ $slcurselcol = 4 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/green/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/green/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
elif [ $slcurselcol = 5 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/blue/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/blue/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
elif [ $slcurselcol = 6 ]; then
cp $INSTALLER_DIR/main/selects/$selpath/purple/selection_big.png $INSTALLER_DIR/hi-theme/selection_big.png
cp $INSTALLER_DIR/main/selects/$selpath/purple/selection_small.png $INSTALLER_DIR/hi-theme/selection_small.png
else
echo "ERROR: Setup failed on getting selectors, if you select right numbers or select preset, contact with me in github"
exit 2
fi
cp $INSTALLER_DIR/main/theme.conf $INSTALLER_DIR/hi-theme/theme.conf
#Setup .config
echo "Setting up theme config..."
outputopt=""
if [ $slconfshd = 1 ]; then
outputopt="showtools shutdown"
fi
if [ $slconfrb = 1 ]; then
if [ -n $outputopt ]; then
outputopt="showtools reboot"
else
outputopt=$outputopt",reboot"
fi
fi
if [ $slconfext = 1 ]; then
if [ -n $outputopt]; then
outputopt="showtools exit"
else
outputopt=$outputopt",exit"
fi
fi
echo $outputopt >> $INSTALLER_DIR/hi-theme/theme.conf
#Check files
echo "Theme created! Check the files..."
errorfl=0
if [ ! -f $INSTALLER_DIR/hi-theme/background.png ]; then errorfl=1; fi
if [ ! -e $INSTALLER_DIR/hi-theme/icons ]; then errorfl=1; fi
if [ ! -f $INSTALLER_DIR/hi-theme/selection_big.png ]; then errorfl=1; fi
if [ ! -f $INSTALLER_DIR/hi-theme/selection_small.png ]; then errorfl=1; fi
if [ ! -f $INSTALLER_DIR/hi-theme/theme.conf ]; then errorfl=1; fi
if [ $errorfl = 1 ]; then
echo "ERROR: Some files not found! Theme not installed. Try again, if this error will repeat, contact with me in github"
exit 2
else
echo "Files founded! Moving theme to refind/themes and add hi-theme to config..."
fi
#exit 0
#Move to refind
mkdir -p $DEST_DIR
cp -r $INSTALLER_DIR/hi-theme/* $DEST_DIR
if [ $deletefiles = 1 ]; then
rm -Rf $INSTALLER_DIR/hi-theme
fi
# Disable other themes
if [ -f "${REFIND_DIR}/refind.conf" ]; then
sed -i -r "/^[[:space:]]*include[[:space:]]themes\/refind-dreary\/theme\.conf/!s/^([[:space:]]*)(include[[:space:]]themes\/)/\1# \2/g" "${REFIND_DIR}/refind.conf"
else
touch "${REFIND_DIR}/refind.conf"
fi
# Include the hi-theme theme
if ! grep -q -e "^[[:space:]]*include[[:space:]]themes/refind-dreary/theme.conf" "$REFIND_DIR/refind.conf"; then
cat >> "${REFIND_DIR}/refind.conf" << EOF
#Run hi-theme
include themes/hi-theme/theme.conf
EOF
fi
#Exit
echo "Succesfully installed hi-theme!"
exit 0