-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·563 lines (434 loc) · 14.1 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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
#!/bin/bash
##################################
############ Menu ############
##################################
update_config() {
local config_dir_path="$HOME/.config/dotfiles-installer"
local config_path="$config_dir_path/config"
if ! test -f $config_path; then
touch $config_path
fi
echo $1 > $config_path
}
source_config() {
local config_dir_path="$HOME/.config/dotfiles-installer"
local config_path="$config_dir_path/config"
source $config_path
}
setup_config() {
local config_dir_path="$HOME/.config/dotfiles-installer"
if ! test -d $config_dir_path; then
mkdir -p $config_dir_path
fi
local config_path="$config_dir_path/config"
if ! test -f $config_path; then
update_config "WL_PATH=/usr/bin/wl"
fi
source_config
}
main_menu() {
setup_config
clear
echo "##########################################"
echo "#### Welcome to my dotfiles installer ####"
echo "##########################################"
echo "----------------------------------------"
echo "Steps:"
printf " 1. Clone the dotfiles (not required if already have)\n"
printf " 2. Install the required programs\n"
printf " 3. Create .config symlinks\n"
printf " 4. Create $HOME symlinks\n"
printf " 5. Create .local/bin symlinks (optional because the step 1 already apply this)\n"
printf " 6. Setup rofi\n"
printf " 7. Make dwm\n"
printf " 8. Setup wl wallpaper\n"
printf " 9. Exit of installer\n"
echo
echo "Uninstall:"
printf " 10. Remove all config\n"
echo "----------------------------------------"
printf "=> Write the option to make: "
read option
while [[ $option < 1 || $option > 9 && "$option" -eq "$option" ]]; do
echo "==> Invalid option!"
printf "=> Write the option to make: "
read option
done
case "$option" in
1) clone_dotfiles ;;
2) install_required_programs ;;
3) create_DOT_config_symlinks ;;
4) create_home_symlinks ;;
5) create_local__bin_symlinks;;
6) setup_rofi ;;
7) make_dwm ;;
8) setup_wallpaper ;;
9) clear && echo "Bye bye. Enjoy!!!" && exit 0;;
10) remove_all_config ;;
esac
}
#################################
########### Functions ###########
#################################
error() {
echo "$1"
exit 1
}
title() {
text=$1
if [[ $text == "" ]]; then
error "Installer error: title text cannot be empty"
fi
sep=""
for (( i=0; i<${#text}; i++ )); do
sep="$sep-"
done
sep="$sep----"
echo "$sep"
echo " $text"
echo "$sep"
echo
}
confirm() {
text=$1
default_response=$2
if [[ $default_response == 1 ]]; then
yn="Y/n"
elif [[ $default_response == 0 ]]; then
yn="y/N"
elif [[ $default_response == "" ]]; then
yn="Y/n"
default_response=1
else
error "confirm error: default_response is distinct than 1, 0 or void"
fi
printf "$text $yn: "
read response
while [[ $response != "y" && $response != "Y" && $response != "n" && $response != "N" && $response != "" ]]; do
printf "Invalid response. $text $yn: "
read response
done
if [[ $response == "y" || $response == "Y" ]]; then
return 0
elif [[ $response == "n" || $response == "N" ]]; then
return 1
else
if [[ $default_response == 1 ]]; then
return 0
else
return 1
fi
fi
}
press_enter_to_continue() {
printf "Press ENTER to continue... "
read
}
prevented_process() {
command=$@
if [[ $command == "" ]]; then
error "program error: prevented_process: command cannot be void"
fi
$command
if [[ $? != 0 ]]; then
if ! confirm "The command \"$command\" was exit without exit status 0, do you want to continue?" 0; then
exit 1
fi
fi
}
install_required_programs() {
clear
title "Install the required programs"
echo "*****************Before run this, install git!****************"
declare -a dependencies=(
"conky",
"nm-applet",
"trayer",
"emacs"
)
pypi_dependencies="wl-wall qtile"
declare -a to_recompile_dependencies=(
"volumeicon",
"rofi",
"nvim",
"picom",
"xmonad",
"xmobar",
"fish",
"cbatticon",
"udiskie",
"bspwm",
"i3",
"spectrwm",
"polybar"
)
declare -a to_manually_install_dependencies=(
"brave-browser",
"colorscript",
"bash-insulter",
"kitty"
)
if confirm "Do you want to install the required programs with apt and git, if not, I list all packages you will install" 1; then
title "Dependencies installing process"
if ! confirm "Do you want to skip the python libraries installing process?" 0; then
printf "Please write the python binary name to use pypi: "
read python
while [[ $python == "" ]]; do
printf "Invalid python binary name. Please write the python binary name to use pypi: "
read python
done
for dependency in $pypi_dependencies; do
echo "==> ${python} -m pip install $dependency"
prevented_process $python -m pip install $dependency
done
fi
if ! confirm "Do you want to skip the apt dependencies installing process?" 0; then
for dependency in ${dependencies[@]}; do
echo "==> sudo apt-get install --yes $dependency"
# Making a stupid sudo echo to prevent password prompt in the apt while
prevented_process sudo echo "sudoconverting..." 2>&1 > /dev/null
prevented_process sudo apt-get install --yes $dependency
done
fi
if confirm "Exists dependencies to recompile manually go to its website, list it?" 1; then
echo "-----------------"
echo "Listing the dependencies to recompile manually..."
for dependency in ${to_recompile_dependencies[@]}; do
echo " -> $dependency"
done
echo "Done."
fi
if confirm "Exists dependencies to install manually go to its website, list it?" 1; then
echo "-----------------"
echo "Listing the dependencies to install manually..."
for dependency in ${to_manually_install_dependencies[@]}; do
echo " -> $dependency"
done
echo "Done."
fi
else
clear
title "Dependencies store"
echo "Listing the apt packages list..."
for dependency in ${dependencies[@]}; do
echo " -> $dependency"
done
echo "Done."
echo "-----------------"
echo "Listing the python (pypi) dependencies..."
for dependency in $pypi_dependencies; do
echo " -> $dependency"
done
echo "Done."
echo "-----------------"
echo "Listing the dependencies to recompile manually..."
for dependency in ${to_recompile_dependencies[@]}; do
echo " -> $dependency"
done
echo "Done."
echo "-----------------"
echo "Listing the dependencies to install manually..."
for dependency in ${to_manually_install_dependencies[@]}; do
echo " -> $dependency"
done
fi
press_enter_to_continue
main_menu
}
clone_dotfiles() {
clear
title "Clone the dotfiles"
echo "*****************Before run this, install git!****************"
repository_url="https://github.com/AlphaTechnolog/dotfiles-old.git"
printf "Write the address to clone the dotfiles directory (default $HOME) (it appends .dotfiles): "
read directory
if [[ $directory == "" ]]; then
directory="$HOME"
fi
while ! confirm "Is this url correct: '$directory/.dotfiles'?"; do
printf "Write the address to clone the dotfiles directory: "
read directory
done
prevented_process git clone $repository_url $directory/.dotfiles
if ! confirm "Do you want to skip the .local/bin custom scripts installing process?" 0; then
echo "==> mkdir -p $HOME/.local/bin/"
mkdir -p $HOME/.local/bin
local__bin_scripts="monitor-config wl-random-wallpaper volume percentage brightness checkupdates audio-toggler wl-wallpapers-rotator wl-wallpapers-previewer spanish-kb-copier random random-wallpaper"
cd $directory/.dotfiles
mkdir -p $HOME/.local/bin
for dependency in $local__bin_scripts; do
echo "==> ln -s $PWD/.local/bin/$dependency $HOME/.local/bin/$dependency"
prevented_process ln -s $PWD/.local/bin/$dependency $HOME/.local/bin/$dependency
done
fi
press_enter_to_continue
main_menu
}
create_DOT_config_symlinks() {
clear
title "Create .config symlinks"
printf "=> Write the .dotfiles folder fullpath (default: $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path="$HOME/.dotfiles"
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to read $dotfiles_path: No such file or directory"
fi
for dirent in $(ls "${dotfiles_path}/.config"); do
echo "==> ln -s $dotfiles_path/.config/$dirent $HOME/.config/$dirent"
prevented_process ln -s $dotfiles_path/.config/$dirent $HOME/.config/$dirent
done
press_enter_to_continue
main_menu
}
create_home_symlinks() {
clear
title "Create home symlinks"
printf "=> Write the .dotfiles folder fullpath (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path="$HOME/.dotfiles"
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to read $dotfiles_path: No such file or directory"
fi
to_paste=".bashrc .xmonad .gtkrc-2.0 .Xresources .tmux.conf .tmux.powerline.conf .tmux.powerline"
for to_paste_item in ${to_paste[@]}; do
if [[ -f $HOME/$to_paste_item ]]; then
echo "==> rm $HOME/$to_paste_item"
rm $HOME/$to_paste_item
fi
echo "==> ln -s $dotfiles_path/$to_paste_item $HOME/$to_paste_item"
prevented_process ln -s $dotfiles_path/$to_paste_item $HOME/$to_paste_item
done
press_enter_to_continue
main_menu
}
create_local__bin_symlinks() {
clear
title "Create .local/bin symlinks"
printf "=> Write the .dotfiles folder fullpath (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path="$HOME/.dotfiles"
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to read $dotfiles_path: No such file or directory"
fi
to_paste="monitor-config wl-random-wallpaper wl-wallpapers-rotator volume percentage brightness checkupdates audio-toggler wl-wallpapers-previewer spanish-kb-copier random random-wallpaper"
for to_paste_item in $to_paste; do
echo "==> ln -s $dotfiles_path/.local/bin/$to_paste_item $HOME/.local/bin/$to_paste_item"
prevented_process ln -s $dotfiles_path/.local/bin/$to_paste_item $HOME/.local/bin/$to_paste_item
done
press_enter_to_continue
main_menu
}
remove_all_config() {
clear
title "Remove all config"
printf "=> Write the cloned dotfiles path (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path="$HOME/.dotfiles"
fi
if confirm "Do you want to remove all .config symlinks?"; then
for dirent in $(ls $dotfiles_path/.config); do
echo "==> rm $HOME/.config/$dirent"
rm $HOME/.config/$dirent
done
if confirm "Neovim has a special uninstallation method, do you want to uninstall it?"; then
echo "==> rm -rf $HOME/.cache/nvim $HOME/.local/share/nvim"
rm -rf $HOME/.cache/nvim $HOME/.local/share/nvim
fi
fi
}
setup_rofi() {
clear
title "Setup rofi"
echo "****To setup rofi I will create the theme file into your .local/share/rofi/themes****"
printf "=> Write the dotfiles folder path (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path=$HOME/.dotfiles
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to open $dotfiles_path: No such file or directory"
fi
echo "==> mkdir -p $HOME/.local/share/rofi/themes"
prevented_process mkdir -p $HOME/.local/share/rofi/themes
echo "==> ln -s $dotfiles_path/.local/share/rofi/themes/onedark.rasi $HOME/.local/share/rofi/themes/onedark.rasi"
prevented_process ln -s $dotfiles_path/.local/share/rofi/themes/onedark.rasi $HOME/.local/share/rofi/themes/onedark.rasi
echo "Done."
press_enter_to_continue
main_menu
}
make_dwm() {
clear
title "Make dwm"
printf "=> Write the dotfiles folder path (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path=$HOME/.dotfiles
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to open $dotfiles_path: No such file or directory"
fi
echo "==> mkdir -p $HOME/.local/share/dwm"
mkdir -p $HOME/.local/share/dwm
echo "==> ln -s $dotfiles_path/.config/dwm $HOME/.config/dwm"
ln -s $dotfiles_path/.config/dwm $HOME/.config/dwm
echo "==> ln -s $HOME/.config/dwm/autostart.sh $HOME/.local/share/dwm/autostart.sh"
ln -s $HOME/.config/dwm/autostart.sh $HOME/.local/share/dwm/autostart.sh
echo "==> cd $HOME/.config/dwm && sudo make clean install"
cd $HOME/.config/dwm && sudo make clean install
echo "==> cd $HOME/.config/dwm/dwmblocks && sudo make clean install"
cd $HOME/.config/dwm/dwmblocks && sudo make clean install
press_enter_to_continue
main_menu
}
exec_wl_cmd() {
cmd=$@
echo "==> $cmd"
$cmd
return $?
}
wl_cmd() {
while ! test -f $WL_PATH; do
printf "WL_PATH config variable is invalid in the config file $HOME/.config/dotfiles-installer/config, it binary does not exists, please give me another"
read wl_binary
update_config "WL_PATH=$wl_binary"
source_config
done
cmd="$WL_PATH $@"
while ! exec_wl_cmd $cmd; do
printf "Cannot use a wl command, please specify the path of the wl binary (e.g: /usr/bin/wl): "
read wl_binary
while ! test -f $wl_binary; do
printf "The file does not exists, please specify a valid wl binary path (e.g: /usr/bin/wl): "
read wl_binary
done
cmd="$wl_binary $@"
update_config "WL_PATH=$wl_binary"
source_config
done
}
setup_wallpaper() {
clear
title "Setup the wl wallpaper"
printf "=> Write the dotfiles path (default $HOME/.dotfiles): "
read dotfiles_path
if [[ $dotfiles_path == "" ]]; then
dotfiles_path="$HOME/.dotfiles"
fi
if [[ ! -d $dotfiles_path ]]; then
error "Error at try to open $dotfiles_path: No such file or directory"
fi
wl_cmd config -k wallpapers_folder -v $dotfiles_path/wallpapers
if confirm "Do you want to setup a default wl wallpaper (45.jpeg)? " 1; then
wl_cmd set 45.jpeg
fi
press_enter_to_continue
main_menu
}
main_menu