-
Notifications
You must be signed in to change notification settings - Fork 6
/
install
executable file
·414 lines (352 loc) · 14.4 KB
/
install
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
#!/usr/bin/env bash
CRE=$(tput setaf 1)
CYE=$(tput setaf 3)
CGR=$(tput setaf 2)
CBL=$(tput setaf 4)
BLD=$(tput bold)
CNC=$(tput sgr0)
backup_folder=~/.RiceBackup
date=$(date +%Y%m%d-%H%M%S)
ERROR_LOG="$HOME/RiceError.log"
logo() {
local text="${1:?}"
echo -en "
1llusion Dotfiles\n\n"
printf ' %s [%s%s %s%s %s]%s\n\n' "${CRE}" "${CNC}" "${CYE}" "${text}" "${CNC}" "${CRE}" "${CNC}"
}
if [ "$(id -u)" = 0 ]; then
echo "This script cannot be run as root user."
exit 1
fi
home_dir=$HOME
current_dir=$(pwd)
if [ "$current_dir" != "$home_dir" ]; then
printf "%s%sThis script must be executed from your \$HOME directory.%s\n" "${BLD}" "${CYE}" "${CNC}"
exit 1
fi
log_error() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >>"$ERROR_LOG"
}
is_installed() {
pacman -Qq "$1" &>/dev/null
}
logo "Welcome!"
printf '%s%sThis script will check if you have the necessary dependencies, and if not, it will install them. Then, it will clone my repository in your $HOME directory.\nAfter that, it will create a backup of your files, and then copy the new files to your computer.\n\nMy dotfiles DO NOT modify any of your system configurations.\nYou will be prompted for your root password to install missing dependencies and/or to switch to zsh shell if its not your default.\n\nThis script doesnt have the potential power to break your system, it only copies files from my repository to your $HOME directory.%s\n\n' "${BLD}" "${CRE}" "${CNC}"
while true; do
read -rp " Continue? [y/N]: " yn
case $yn in
[Yy]*) break ;;
[Nn]*) exit ;;
*) printf " Error: please enter 'y' or 'n'\n\n" ;;
esac
done
clear
logo "Installing needed packages..."
dependencies=(alacritty base-devel bat brightnessctl bspwm dunst eza feh firefox git kitty imagemagick jq
jgmenu libwebp maim mpc mpd mpv neovim ncmpcpp npm pamixer pacman-contrib
papirus-icon-theme picom playerctl polybar polkit-gnome python-gobject
redshift rofi rustup sxhkd ttf-inconsolata ttf-jetbrains-mono ttf-jetbrains-mono-nerd
ttf-joypixels ttf-terminus-nerd ttf-ubuntu-mono-nerd ueberzug webp-pixbuf-loader xclip xdg-user-dirs
xdo xdotool xsettingsd xorg-xdpyinfo xorg-xkill xorg-xprop xorg-xrandr xorg-xsetroot
xorg-xwininfo yazi zsh zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting
)
printf "%s%sChecking for required packages...%s\n\n" "${BLD}" "${CBL}" "${CNC}"
for pkg in "${dependencias[@]}"; do
if ! is_installed "$pkg"; then
if sudo pacman -S "$pkg" --noconfirm >/dev/null 2> >(tee -a "$ERROR_LOG"); then
printf "%s%s%s %sinstalled succesfully.%s\n" "${BLD}" "${CYE}" "$pkg" "${CBL}" "${CNC}"
else
printf "%s%s%s %snot installed correctly. Check %sRiceError.log %sfor more details.%s\n" \
"${BLD}" "${CYE}" "$pkg" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
log_error "Failed to install package: $pkg"
fi
sleep 1
else
printf "%s%s%s %sis already installed!%s\n" "${BLD}" "${CYE}" "$pkg" "${CGR}" "${CNC}"
sleep 1
fi
done
sleep 3
clear
logo "Add custom repository mirror"
REPO_CONTENT="[gh0stzk-dotfiles]
SigLevel = Optional TrustAll
Server = http://gh0stzk.github.io/pkgs/x86_64"
if ! grep -q "\[gh0stzk-dotfiles\]" /etc/pacman.conf; then
if echo -e "\n$REPO_CONTENT" | sudo tee -a /etc/pacman.conf >/dev/null 2>>RiceError.log; then
printf "%s%sgh0stzk-dotfiles%s repository added succesfully.%s\n" "${BLD}" "${CYE}" "${CGR}" "${CNC}"
sudo pacman -Syy
else
printf "%s%sFailded to add repository mirror. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "${CBL}" "${CYE}" "${CNC}"
fi
else
printf "Repository mirror already exists in /etc/pacman.conf"
sleep 1
fi
sleep 3
clear
logo "Installing needed packages from custom repository"
dependencies=(gh0stzk-gtk-themes gh0stzk-cursor-qogirr
gh0stzk-icons-beautyline gh0stzk-icons-candy gh0stzk-icons-catppuccin-mocha gh0stzk-icons-dracula gh0stzk-icons-glassy
gh0stzk-icons-gruvbox-plus-dark gh0stzk-icons-hack gh0stzk-icons-luv gh0stzk-icons-sweet-rainbow gh0stzk-icons-tokyo-night
gh0stzk-icons-vimix-white gh0stzk-icons-zafiro gh0stzk-icons-zafiro-purple)
printf "%s%sChecking for required custom packages...%s\n" "${BLD}" "${CBL}" "${CNC}"
for pkg in "${dependencies[@]}"; do
if ! is_installed "$pkg"; then
if sudo pacman -S "$pkg" --noconfirm >/dev/null 2>>RiceError.log; then
printf "%s%s%s %sinstalled succesfully.%s\n" "${BLD}" "${CYE}" "$pkg" "${CBL}" "${CNC}"
sleep 1
else
printf "%s%s%s %snot installed correctly. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "$pkg" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
else
printf '%s%s%s %sis already installed!%s\n' "${BLD}" "${CYE}" "$pkg" "${CGR}" "${CNC}"
sleep 1
fi
done
sleep 5
clear
if [ ! -e "$HOME/.config/user-dirs.dirs" ]; then
xdg-user-dirs-update
fi
logo "Downloading dotfiles"
repo_url="https://github.com/CuB3y0nd/1llusion"
repo_dir="$HOME/dotfiles"
if [ -d "$repo_dir" ]; then
printf "Remove existing dotfiles repository\n"
rm -rf "$repo_dir"
fi
printf "Cloning dotfiles from %s\n" "$repo_url"
git clone --depth=1 --recursive "$repo_url" "$repo_dir"
cd $repo_dir
git submodule update --remote
cd -
sleep 3
clear
logo "Backup files"
printf "If you already have a powerful and super Pro NEOVIM configuration, write 'n' in the next question. If you answer 'y' your neovim configuration will be moved to the backup directory.\n\n"
while true; do
read -rp "Do you want to try my nvim config? (y/n): " try_nvim
if [[ "$try_nvim" == "y" || "$try_nvim" == "n" ]]; then
break
else
echo "Invalid input. Please enter 'y' or 'n'."
fi
done
printf "\nBackup files will be stored in %s%s%s/.RiceBackup%s \n\n" "${BLD}" "${CRE}" "$HOME" "${CNC}"
sleep 10
[ ! -d "$backup_folder" ] && mkdir -p "$backup_folder"
for folder in bspwm alacritty picom rofi eww sxhkd dunst kitty polybar gtk-3.0 ncmpcpp yazi zsh mpd; do
if [ -d "$HOME/.config/$folder" ]; then
if mv "$HOME/.config/$folder" "$backup_folder/${folder}_$date" 2>>RiceError.log; then
printf "%s%s%s backed up successfully at %s%s/%s_%s%s\n" "${BLD}" "${CGR}" "$folder" "${CBL}" "$backup_folder" "$folder" "$date" "${CNC}"
sleep 1
else
printf "%s%sFailed to backup %s. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CRE}" "$folder" "${CBL}" "${CNC}"
sleep 1
fi
else
printf "%s%s%s does not exists, %sskipped.%s\n" "${BLD}" "${CGR}" "$folder" "${CYE}" "${CNC}"
sleep 1
fi
done
if [[ $try_nvim == "y" ]]; then
if [ -d "$HOME/.config/nvim" ]; then
if mv "$HOME/.config/nvim" "$backup_folder/nvim_$date" 2>>RiceError.log; then
printf "%s%snvim backed up successfully at %s%s/nvim_%s%s\n" "${BLD}" "${CGR}" "${CBL}" "$backup_folder" "$date" "${CNC}"
sleep 1
else
printf "%s%sFailed to backup nvim. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CRE}" "${CBL}" "${CNC}"
sleep 1
fi
else
printf "%s%snvim does not exists, %sskipped.%s\n" "${BLD}" "${CGR}" "${CYE}" "${CNC}"
sleep 1
fi
fi
if [ -f ~/.zshrc ]; then
if mv ~/.zshrc "$backup_folder"/.zshrc_"$date" 2>>RiceError.log; then
printf "%s%s.zshrc backed up successfully at %s%s/.zshrc_%s%s\n" "${BLD}" "${CGR}" "${CBL}" "$backup_folder" "${date}" "${CNC}"
else
printf "%s%sFailed to backup .zshrc. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CRE}" "${CBL}" "${CNC}"
fi
else
printf "%s%s.zshrc does not exists, %sskipped.%s\n" "${BLD}" "${CGR}" "${CYE}" "${CNC}"
fi
if [ -f ~/.gtkrc-2.0 ]; then
if mv ~/.gtkrc-2.0 "$backup_folder"/.gtkrc-2.0_"$date" 2>>RiceError.log; then
printf "%s%s.gtkrc-2.0 backed up successfully at %s%s/.gtkrc-2.0_%s%s\n" "${BLD}" "${CGR}" "${CBL}" "$backup_folder" "${date}" "${CNC}"
else
printf "%s%sFailed to backup .gtkrc-2.0. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CRE}" "${CBL}" "${CNC}"
fi
else
printf "%s%s.gtkrc-2.0 does not exists, %sskipped.%s\n" "${BLD}" "${CGR}" "${CYE}" "${CNC}"
fi
if [ -d ~/.icons ]; then
if mv ~/.icons "$backup_folder"/.icons"$date" 2>>RiceError.log; then
printf "%s%s.icons backed up successfully at %s%s/.icons_%s%s\n" "${BLD}" "${CGR}" "${CBL}" "$backup_folder" "${date}" "${CNC}"
else
printf "%s%sFailed to backup .icons. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CRE}" "${CBL}" "${CNC}"
fi
else
printf "%s%s.icons does not exists, %sskipped.%s\n" "${BLD}" "${CGR}" "${CYE}" "${CNC}"
fi
printf "%s%sDone!%s\n\n" "${BLD}" "${CGR}" "${CNC}"
sleep 3
clear
logo "Installing dotfiles..."
printf "Copying files to respective directories...\n"
[ ! -d ~/.config ] && mkdir -p ~/.config
[ ! -d ~/.config/zsh ] && mkdir -p ~/.config/zsh
[ ! -d ~/.local/bin ] && mkdir -p ~/.local/bin
[ ! -d ~/.local/share ] && mkdir -p ~/.local/share
for dirs in ~/dotfiles/config/*; do
dir_name=$(basename "$dirs")
if [[ $dir_name == "nvim" && $try_nvim != "y" ]]; then
continue
fi
if cp -R "${dirs}" ~/.config/ 2>>RiceError.log; then
printf "%s%s%s %sconfiguration setted up succesfully%s\n" "${BLD}" "${CYE}" "${dir_name}" "${CGR}" "${CNC}"
sleep 1
else
printf "%s%s%s %sconfiguration failed to been setting. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "${dir_name}" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
done
for folder in applications asciiart fonts; do
if cp -R ~/dotfiles/misc/$folder ~/.local/share/ 2>>RiceError.log; then
printf "%s%s%s %scopied succesfully!%s\n" "${BLD}" "${CYE}" "$folder" "${CGR}" "${CNC}"
sleep 1
else
printf "%s%s%s %sfailed to been copied. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "$folder" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
done
if cp -R ~/dotfiles/misc/bin ~/.local/ 2>>RiceError.log; then
printf "%s%sbin %scopied succesfully!%s\n" "${BLD}" "${CYE}" "${CGR}" "${CNC}"
sleep 1
else
printf "%s%sbin %sfailed to been copied. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
if cp -R ~/dotfiles/home/.icons "$HOME" 2>>RiceError.log; then
printf "%s%s.icons %scopied succesfully!%s\n" "${BLD}" "${CYE}" "${CGR}" "${CNC}"
sleep 1
else
printf "%s%s.icons %sfailed to been copied. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
if cp ~/dotfiles/home/zsh/* ~/.config/zsh 2>>RiceError.log; then
printf "%s%szsh configuration files %scopied succesfully!%s\n" "${BLD}" "${CYE}" "${CGR}" "${CNC}"
sleep 1
else
printf "%s%szsh configuration files %sfailed to been copied. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
sleep 1
fi
cp -f "$HOME"/dotfiles/home/.zshrc "$HOME"
cp -f "$HOME"/dotfiles/home/.gtkrc-2.0 "$HOME"
fc-cache -rv >/dev/null 2>&1
printf "\n\n%s%sFiles copied succesfully!%s\n" "${BLD}" "${CGR}" "${CNC}"
sleep 3
clear
logo "Install yay package manager"
if command -v yay >/dev/null 2>&1; then
printf "%s%syay is already installed!%s\n" "${BLD}" "${CGR}" "${CNC}"
else
printf "%s%sInstalling yay...%s\n" "${BLD}" "${CBL}" "${CNC}"
{
cd
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay || exit
makepkg -si --noconfirm
cd
rm -rf yay
} || {
printf "\n%s%sFailed to install yay. You may need to install it manually.%s\n" "${BLD}" "${CRE}" "${CNC}"
}
fi
sleep 3
clear
logo "Install AUR packages"
aur_apps=(tdrop-git xqp rofi-greenclip xwinwrap-0.9-bin ttf-maple i3lock-color eww-git)
printf "%s%sChecking for required packages...%s\n\n" "${BLD}" "${CBL}" "${CNC}"
for aur_package in "${aur_apps[@]}"; do
if ! is_installed "$aur_package"; then
if yay -S --noconfirm "$aur_package" 2> >(tee -a "$ERROR_LOG"); then
printf "%s%s%s %shas been installed succesfully!%s\n" "${BLD}" "${CYE}" "$aur_package" "${CBL}" "${CNC}"
sleep 1
else
printf "%s%s%s %snot installed correctly. Check %sRiceError.log %sfor more details.%s\n" "${BLD}" "${CYE}" "$aur_package" "${CRE}" "${CBL}" "${CRE}" "${CNC}"
log_error "Failed to install package: $aur_package"
fi
else
printf '%s%s%s %sis already installed!%s\n' "${BLD}" "${CYE}" "$aur_package" "${CGR}" "${CNC}"
sleep 1
fi
done
sleep 3
clear
logo "Enabling mpd service"
if systemctl is-enabled --quiet mpd.service; then
printf "%s%sDisabling and stopping the global mpd service...%s\n" "${BLD}" "${CBL}" "${CNC}"
if sudo systemctl disable --now mpd.service >/dev/null 2> >(tee -a "$ERROR_LOG"); then
sleep 1
printf "\n%s[%sOK%s%s]%s Global MPD service disabled successfully!\n\n" \
"${BLD}" "${CGR}" "${CNC}" "${BLD}" "${CNC}"
else
sleep 1
printf "%s[%sError%s%s] Check %sRiceError.log%s for more details.\n\n" \
"${BLD}" "${CRE}" "${CNC}" "${BLD}" "${CYE}" "${CNC}"
log_error "Failed to disable global MPD service."
fi
fi
printf "%s%sEnabling and starting the user-level mpd service...%s\n\n" "${BLD}" "${CBL}" "${CNC}"
if systemctl --user enable --now mpd.service >/dev/null 2> >(tee -a "$ERROR_LOG"); then
sleep 1
printf "%s[%sOK%s%s]%s User-level MPD service enabled successfully!\n\n" \
"${BLD}" "${CGR}" "${CNC}" "${BLD}" "${CNC}"
else
sleep 1
printf "%s[%sError%s%s] Check %sRiceError.log%s for more details.\n\n" \
"${BLD}" "${CRE}" "${CNC}" "${BLD}" "${CYE}" "${CNC}"
log_error "Failed to enable user-level MPD service."
fi
sleep 3
clear
logo "Changing the default shell to zsh"
if [[ $SHELL != "/usr/bin/zsh" ]]; then
printf "%s%sChanging your shell to zsh...%s\n\n" "${BLD}" "${CYE}" "${CNC}"
if chsh -s /usr/bin/zsh 2> >(tee -a "$ERROR_LOG"); then
printf "\n%s[%sOK%s%s] Shell changed to zsh successfully!%s\n\n" "${BLD}" "${CGR}" "${CNC}" "${BLD}" "${CNC}"
else
printf "%s%sAn error occurs in changing your shell to zsh. Check %sRiceError.log%s for more details.%s\n\n" \
"${BLD}" "${CRE}" "${CYE}" "${CRE}" "${CNC}"
log_error "Failed to change the shell to zsh."
fi
else
printf "%s%sYour shell is already changed to zsh.%s\n\n" "${BLD}" "${CGR}" "${CNC}"
fi
sleep 3
clear
logo "Installation complete"
printf "%sThe installation is complete, you %sshould%s restart your machine.%s\n\n" "${BLD}" "${CBL}" "${CNC}" "${CNC}"
while true; do
read -rp " Reboot now? [y/N]: " yn
case $yn in
[Yy]*)
printf "\n%s%sRebooting...%s\n" "${BLD}" "${CGR}" "${CNC}"
sleep 3
reboot
break
;;
[Nn]*)
printf "\n%s%sOK, remember to restart later!%s\n\n" "${BLD}" "${CYE}" "${CNC}"
break
;;
*)
printf "\n%s%sPlease answer yes or no.%s\n\n" "${BLD}" "${CRE}" "${CNC}"
;;
esac
done