-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
ยท373 lines (308 loc) ยท 14 KB
/
install.sh
File metadata and controls
executable file
ยท373 lines (308 loc) ยท 14 KB
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
#!/bin/bash
# ==========================================
# RAINZ's Arch Hyprland Rice Installer (Ultimate Edition)
# ==========================================
# ------------------------------------------
# ๐จ UI & THEME CONFIGURATION (Tokyo Night Inspired)
# ------------------------------------------
COLOR_PRIMARY="#7aa2f7" # Blue
COLOR_SECONDARY="#bb9af7" # Purple
COLOR_ACCENT="#7dcfff" # Cyan
COLOR_SUCCESS="#9ece6a" # Green
COLOR_ERROR="#f7768e" # Red
COLOR_WARNING="#e0af68" # Yellow
COLOR_TEXT="#c0caf5" # Light Gray
COLOR_BG="#1a1b26" # Dark Background
UI_WIDTH=80 # Slightly wider for a breathable layout
# ------------------------------------------
# ๐ SUDO CACHE
# ------------------------------------------
clear
gum style --foreground "$COLOR_WARNING" --bold "๐ Requesting administrative privileges..."
sudo -v
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
SUDO_PID=$!
# ------------------------------------------
# ๐ก๏ธ GLOBAL ERROR HANDLER
# ------------------------------------------
error_handler() {
local line=$1
local exit_code=$2
kill $SUDO_PID 2>/dev/null
clear
gum style --margin "1 auto" --width "$UI_WIDTH" --border rounded --border-foreground "$COLOR_ERROR" --padding "1 2" \
"$(gum style --foreground "$COLOR_ERROR" --bold "๐ฅ CRITICAL ERROR")
Script crashed on line $line (Exit Code: $exit_code)
$(gum style --foreground "$COLOR_WARNING" "Don't panic! Here is how to recover:")
1. Package download failed? Run: $(gum style --foreground "$COLOR_ACCENT" "sudo pacman -Sy archlinux-keyring && sudo pacman -Syu")
2. Git clone failed? Check your internet connection.
Fix the issue and run this script again. $(gum style --foreground "$COLOR_SUCCESS" "It is completely safe to re-run.")"
exit $exit_code
}
set -e
trap 'error_handler ${LINENO} $?' ERR
# ------------------------------------------
# ๐
UI HELPER FUNCTIONS
# ------------------------------------------
print_header() {
clear
gum style \
--border double \
--align center --width "$UI_WIDTH" --margin "1 auto" --padding "1 2" \
--border-foreground "$COLOR_SECONDARY" --foreground "$COLOR_ACCENT" --bold \
"โจ RAINZ's ARCH HYPRLAND SETUP โจ" \
"$(gum style --foreground "$COLOR_TEXT" --faint "A meticulously crafted Wayland experience")"
}
print_step() {
gum style --margin "1 0 0 0" --padding "0 2" --background "$COLOR_PRIMARY" --foreground "$COLOR_BG" --bold " $1 "
}
print_info() {
gum style --margin "0 0 0 2" --foreground "$COLOR_ACCENT" "โน๏ธ $1"
}
print_success() {
gum style --margin "0 0 0 2" --foreground "$COLOR_SUCCESS" "โ $1"
}
print_error() {
gum style --margin "0 0 0 2" --foreground "$COLOR_ERROR" "โ $1"
}
# ------------------------------------------
# ๐ฆ SMART INSTALLATION WRAPPERS
# ------------------------------------------
install_pacman() {
local missing=""
for pkg in $1; do
if ! pacman -Qq "$pkg" &>/dev/null; then
missing="$missing $pkg"
fi
done
missing=$(echo "$missing" | xargs)
if [ -z "$missing" ]; then
print_success "Already installed: $1"
return 0
fi
print_info "Missing packages: $missing"
if ! gum spin --spinner dot --spinner.foreground "$COLOR_SECONDARY" --title " Installing via pacman..." -- sudo pacman -S --needed --noconfirm $missing >/dev/null 2>&1; then
print_error "Pacman failed. Running openly to show the error:"
sudo pacman -S --needed --noconfirm $missing
exit 1
fi
}
install_aur() {
local missing=""
for pkg in $1; do
if ! pacman -Qq "$pkg" &>/dev/null; then
missing="$missing $pkg"
fi
done
missing=$(echo "$missing" | xargs)
if [ -z "$missing" ]; then
print_success "Already installed (AUR): $1"
return 0
fi
print_info "Missing AUR packages: $missing"
if ! gum spin --spinner dot --spinner.foreground "$COLOR_SECONDARY" --title " Installing via yay..." -- yay -S --needed --noconfirm $missing >/dev/null 2>&1; then
print_error "Yay failed. Running openly to show the error:"
yay -S --needed --noconfirm $missing
exit 1
fi
}
# ==========================================
# 0. BOOTSTRAP (Silent/Required)
# ==========================================
clear
gum spin --spinner line --spinner.foreground "$COLOR_ACCENT" --title " Checking system requirements..." -- sleep 1
if [ ! -d "$HOME/dotfiles" ]; then
gum style --foreground "$COLOR_ERROR" --bold "[!] Error: ~/dotfiles directory not found."
gum style --foreground "$COLOR_TEXT" "Please clone your dotfiles repository to your home folder first."
exit 1
fi
sudo pacman -S --needed --noconfirm base-devel git curl wget unzip stow >/dev/null 2>&1
if ! command -v gum &>/dev/null; then
echo -e "\e[34mInstalling 'gum' for UI components...\e[0m"
if ! sudo pacman -S --needed gum --noconfirm; then
echo -e "\e[31m[!] Failed to install 'gum'. Please check your internet connection or pacman lock.\e[0m"
exit 1
fi
fi
# ==========================================
# 1. INSTALLATION MODE SELECTION
# ==========================================
print_header
print_step "โ๏ธ INSTALLATION MODE"
INSTALL_MODE=$(gum choose --cursor="โฏ " --cursor.foreground="$COLOR_ACCENT" --item.foreground="$COLOR_TEXT" --selected.foreground="$COLOR_SUCCESS" \
"๐ Express (Install EVERYTHING automatically)" \
"๐ ๏ธ Custom (Step-by-step granular selection)")
print_step "๐ฎ GPU DRIVER (Mandatory)"
GPU_CHOICE=$(gum choose --cursor="โฏ " --cursor.foreground="$COLOR_ACCENT" --item.foreground="$COLOR_TEXT" --selected.foreground="$COLOR_SUCCESS" \
"NVIDIA" "AMD" "Intel" "Skip (Already Installed)")
if [[ "$INSTALL_MODE" == *"Express"* ]]; then
print_step "๐ EXPRESS MODE ACTIVE"
print_info "Buckle up! All features will be installed."
sleep 2
DO_UPDATE="yes"
INSTALL_HYPR="yes"
INSTALL_NOCT="yes"
INSTALL_AUDIO="yes"
INSTALL_BT="yes"
INSTALL_FONTS="yes"
EXTRAS="Ghostty Kitty Wezterm Zen Browser Yazi Zathura Fetch Tools"
WANT_NVIM="yes"
else
print_step "๐ SYSTEM MAINTENANCE"
gum style --margin "0 0 0 2" "Perform a full system update?"
DO_UPDATE=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
print_step "๐ช CORE DESKTOP ELEMENTS"
gum style --margin "0 0 0 2" "1. Install Hyprland & Wayland base?"
INSTALL_HYPR=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
gum style --margin "0 0 0 2" "2. Install Noctalia Shell (Bar, Notifications)?"
INSTALL_NOCT=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
gum style --margin "0 0 0 2" "3. Install Audio Subsystem (Pipewire)?"
INSTALL_AUDIO=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
gum style --margin "0 0 0 2" "4. Install Bluetooth Subsystem (Bluez)?"
INSTALL_BT=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
gum style --margin "0 0 0 2" "5. Install Nerd Fonts & Starship Prompt?"
INSTALL_FONTS=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
print_step "๐ฆ EXTRA APPLICATIONS"
EXTRAS=$(gum choose --no-limit --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " \
--cursor.foreground="$COLOR_ACCENT" --selected.foreground="$COLOR_SUCCESS" --item.foreground="$COLOR_TEXT" \
"Ghostty" "Kitty" "Wezterm" "Zen Browser" "Yazi" "Zathura" "Fetch Tools")
print_step "โ๏ธ DEVELOPMENT ENVIRONMENT"
gum style --margin "0 0 0 2" "Install RAINZ's custom Neovim setup?"
WANT_NVIM=$(gum confirm --selected.background="$COLOR_PRIMARY" --selected.foreground="$COLOR_BG" && echo "yes" || echo "no")
fi
# ==========================================
# 2. ๐ก๏ธ PRE-FLIGHT BACKUP
# ==========================================
print_header
gum style --align center --width "$UI_WIDTH" --margin "0 auto" --foreground "$COLOR_SUCCESS" --bold "๐ COMMENCING INSTALLATION..."
BACKUP_DIR="$HOME/.config.bak_$(date +%Y%m%d_%H%M%S)"
gum spin --spinner points --spinner.foreground "$COLOR_SECONDARY" --title " Backing up existing configs to $BACKUP_DIR..." -- sleep 2
mkdir -p "$BACKUP_DIR"
TARGET_CONFIGS=("nvim" "fish" "starship" "rofi" "hypr" "noctalia" "tmux" "ghostty" "kitty" "wezterm" "yazi" "zathura" "bat" "fastfetch")
for app in "${TARGET_CONFIGS[@]}"; do
if [ -d "$HOME/.config/$app" ]; then
cp -r "$HOME/.config/$app" "$BACKUP_DIR/" 2>/dev/null || true
fi
done
# ==========================================
# 3. EXECUTION PHASE
# ==========================================
if [[ "$DO_UPDATE" == "yes" ]]; then
print_step "๐ SYSTEM UPDATE"
gum spin --spinner dot --spinner.foreground "$COLOR_ACCENT" --title " Syncing Arch mirrors..." -- sudo pacman -Syu --noconfirm >/dev/null 2>&1
print_success "System is up to date."
fi
if ! command -v yay &>/dev/null; then
print_step "๐ฆ COMPILING AUR HELPER"
gum spin --spinner dot --spinner.foreground "$COLOR_ACCENT" --title " Building yay..." -- bash -c "rm -rf /tmp/yay && git clone https://aur.archlinux.org/yay.git /tmp/yay >/dev/null 2>&1 && cd /tmp/yay && makepkg -si --noconfirm"
cd ~/dotfiles
fi
print_step "๐ฎ GPU DRIVERS ($GPU_CHOICE)"
case $GPU_CHOICE in
"NVIDIA") install_pacman "nvidia nvidia-utils nvidia-settings" ;;
"AMD") install_pacman "mesa lib32-mesa vulkan-radeon lib32-vulkan-radeon" ;;
"Intel") install_pacman "mesa lib32-mesa vulkan-intel lib32-vulkan-intel" ;;
*) print_info "Skipping GPU drivers." ;;
esac
if [[ "$INSTALL_HYPR" == "yes" ]]; then
print_step "๐ช WINDOW MANAGER"
install_pacman "hyprland xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal-gtk wayland wlroots rofi-wayland hyprpaper thunar tmux brightnessctl"
fi
if [[ "$INSTALL_NOCT" == "yes" ]]; then
print_step "๐ NOCTALIA SHELL"
install_aur "noctalia-shell vicinae"
fi
if [[ "$INSTALL_AUDIO" == "yes" ]]; then
print_step "๐ AUDIO SUBSYSTEM"
install_pacman "pipewire pipewire-pulse pipewire-alsa wireplumber pavucontrol"
fi
if [[ "$INSTALL_BT" == "yes" ]]; then
print_step "๐ถ BLUETOOTH"
install_pacman "bluez bluez-utils blueman"
fi
if [[ "$INSTALL_FONTS" == "yes" ]]; then
print_step "๐ค TYPOGRAPHY & TERMINAL"
install_pacman "ttf-jetbrains-mono-nerd starship fish"
fi
print_step "๐ฆ EXTRA APPLICATIONS"
if [ -z "$EXTRAS" ]; then
print_info "No extras selected."
else
if [[ $EXTRAS == *"Ghostty"* ]]; then sudo pacman -S --needed --noconfirm ghostty >/dev/null 2>&1 || install_aur "ghostty-git"; fi
if [[ $EXTRAS == *"Kitty"* ]]; then install_pacman "kitty"; fi
if [[ $EXTRAS == *"Wezterm"* ]]; then install_pacman "wezterm"; fi
if [[ $EXTRAS == *"Zen Browser"* ]]; then install_aur "zen-browser-bin"; fi
if [[ $EXTRAS == *"Yazi"* ]]; then install_pacman "yazi"; fi
if [[ $EXTRAS == *"Zathura"* ]]; then install_pacman "zathura zathura-pdf-mupdf"; fi
if [[ $EXTRAS == *"Fetch Tools"* ]]; then install_aur "bat fastfetch kotofetch"; fi
fi
if [[ "$WANT_NVIM" == "yes" ]]; then
print_step "โ๏ธ NEOVIM ENVIRONMENT"
install_pacman "neovim wl-clipboard ripgrep fd nodejs npm gcc"
rm -rf ~/.config/nvim ~/.local/share/nvim ~/.local/state/nvim ~/.cache/nvim
gum spin --spinner dot --spinner.foreground "$COLOR_ACCENT" --title " Fetching RAINZ configuration..." -- git clone https://github.com/R7rainz/neovim-conf ~/.config/nvim >/dev/null 2>&1
print_success "Neovim configured."
fi
# ==========================================
# 4. SAFE STOWING
# ==========================================
print_step "๐ DEPLOYING DOTFILES"
safe_stow() {
local app=$1
if [ -d "$HOME/dotfiles/$app" ]; then
# || true prevents stow errors from triggering the set -e crash trap
gum spin --spinner mini --spinner.foreground "$COLOR_SECONDARY" --title " Stowing $app..." -- stow --adopt "$app" >/dev/null 2>&1 || true
fi
}
cd ~/dotfiles || exit 1
if [[ "$INSTALL_FONTS" == "yes" ]]; then safe_stow fish && safe_stow starship; fi
if [[ "$INSTALL_HYPR" == "yes" ]]; then safe_stow rofi && safe_stow hyprland && safe_stow tmux; fi
if [[ "$INSTALL_NOCT" == "yes" ]]; then safe_stow noctalia; fi
if [[ $EXTRAS == *"Ghostty"* ]]; then safe_stow ghostty; fi
if [[ $EXTRAS == *"Kitty"* ]]; then safe_stow kitty; fi
if [[ $EXTRAS == *"Wezterm"* ]]; then safe_stow wezterm; fi
if [[ $EXTRAS == *"Yazi"* ]]; then safe_stow yazi; fi
if [[ $EXTRAS == *"Zathura"* ]]; then safe_stow zathura; fi
if [[ $EXTRAS == *"Fetch Tools"* ]]; then safe_stow bat && safe_stow fastfetch; fi
git restore . >/dev/null 2>&1 || true
print_success "Symlinks created successfully."
# ==========================================
# 5. SYSTEM SERVICES
# ==========================================
print_step "โ๏ธ SYSTEM SERVICES"
if [[ "$INSTALL_AUDIO" == "yes" ]]; then
systemctl --user enable --now pipewire pipewire-pulse wireplumber >/dev/null 2>&1 || true
print_success "Audio services enabled."
fi
if [[ "$INSTALL_BT" == "yes" ]]; then
sudo systemctl enable bluetooth >/dev/null 2>&1 || true
print_success "Bluetooth daemon enabled."
fi
if [[ "$INSTALL_FONTS" == "yes" ]]; then
if ! grep -q "/usr/bin/fish" /etc/shells; then
echo /usr/bin/fish | sudo tee -a /etc/shells >/dev/null
fi
sudo chsh -s /usr/bin/fish "$USER" >/dev/null 2>&1 || true
print_success "Default shell set to Fish."
fi
# ==========================================
# 6. COMPLETION
# ==========================================
trap - ERR
kill $SUDO_PID 2>/dev/null || true
clear
gum style \
--border double --border-foreground "$COLOR_SUCCESS" \
--align center --width "$UI_WIDTH" --margin "1 auto" --padding "1 2" \
"$(gum style --foreground "$COLOR_SUCCESS" --bold "๐ INSTALLATION COMPLETE! ๐")" \
"" \
"$(gum style --foreground "$COLOR_TEXT" "Your Wayland environment has been meticulously crafted.")" \
"$(gum style --foreground "$COLOR_TEXT" "Please reboot your system to apply all shell and service changes.")" \
"" \
"$(gum style --foreground "$COLOR_WARNING" "Backups saved to:")" \
"$(gum style --foreground "$COLOR_ACCENT" "$BACKUP_DIR")"
echo ""