-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·613 lines (528 loc) · 18.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·613 lines (528 loc) · 18.8 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
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
#!/bin/bash
# =============================================================================
#
# █ █▄█ █▄ █ █▀▀ ▄▄ █▀▄ █▀█ ▀█▀ █▀
# █▄▄ █ █ ▀█ ██▄ █▄▀ █▄█ █ ▄█
#
# Installation Script
# https://github.com/caioax/lyne-dots
#
# =============================================================================
set -e
# =============================================================================
# Configuration
# =============================================================================
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PACKAGES_DIR="$DOTFILES_DIR/.install/packages"
SETUP_DIR="$DOTFILES_DIR/.install/setup"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
# =============================================================================
# Logging functions
# =============================================================================
log_header() {
echo ""
echo -e "${MAGENTA}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${MAGENTA} $1${NC}"
echo -e "${MAGENTA}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
}
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
log_step() { echo -e "${CYAN}[>>]${NC} $1"; }
# =============================================================================
# Initial checks
# =============================================================================
check_arch() {
if [[ ! -f /etc/arch-release ]]; then
log_error "This script is for Arch Linux only!"
exit 1
fi
}
check_internet() {
log_step "Checking internet connection..."
if ! ping -c 1 google.com &>/dev/null; then
log_error "No internet connection!"
exit 1
fi
log_info "Connection OK"
}
check_aur_helper() {
if command -v yay &>/dev/null; then
AUR_HELPER="yay"
elif command -v paru &>/dev/null; then
AUR_HELPER="paru"
else
log_warn "No AUR helper found (yay/paru)"
log_info "Installing yay..."
install_yay
AUR_HELPER="yay"
fi
log_info "AUR helper: $AUR_HELPER"
}
install_yay() {
sudo pacman -S --needed --noconfirm git base-devel
local TEMP_DIR=$(mktemp -d)
git clone https://aur.archlinux.org/yay.git "$TEMP_DIR/yay"
cd "$TEMP_DIR/yay"
makepkg -si --noconfirm
cd "$DOTFILES_DIR"
rm -rf "$TEMP_DIR"
}
# =============================================================================
# Package installation
# =============================================================================
install_packages() {
local CATEGORY=$1
local PACKAGES_FILE="$PACKAGES_DIR/${CATEGORY}.sh"
if [[ ! -f "$PACKAGES_FILE" ]]; then
log_error "Package file not found: $PACKAGES_FILE"
return 1
fi
# Load package arrays
source "$PACKAGES_FILE"
local ARRAY_NAME="${CATEGORY^^}_PACKAGES"
local AUR_ARRAY_NAME="${CATEGORY^^}_AUR_PACKAGES"
# Convert to array using nameref
local -n PACKAGES_REF="$ARRAY_NAME" 2>/dev/null || true
local -n AUR_PACKAGES_REF="$AUR_ARRAY_NAME" 2>/dev/null || true
# Install official packages
if [[ ${#PACKAGES_REF[@]} -gt 0 ]]; then
log_step "Installing official packages ($CATEGORY)..."
sudo pacman -S --needed --noconfirm "${PACKAGES_REF[@]}" || {
log_warn "Some packages may not be available"
}
fi
# Install AUR packages
if [[ ${#AUR_PACKAGES_REF[@]} -gt 0 ]]; then
log_step "Installing AUR packages ($CATEGORY)..."
$AUR_HELPER -S --needed --noconfirm "${AUR_PACKAGES_REF[@]}" || {
log_warn "Some AUR packages may not be available"
}
fi
}
# =============================================================================
# Category selection menu
# =============================================================================
show_menu() {
echo ""
echo -e "${CYAN}Select categories to install:${NC}"
echo ""
echo " 1) core - Hyprland, UWSM, portal (ESSENTIAL)"
echo " 2) terminal - Kitty, Zsh, Tmux, Fastfetch"
echo " 3) editor - Neovim + development tools"
echo " 4) apps - Dolphin, Zen Browser, Spotify, mpv"
echo " 5) utils - Clipboard, playerctl, audio, etc"
echo " 6) fonts - Nerd Fonts, cursors, icons"
echo " 7) quickshell - QuickShell bar/shell"
echo " 8) theming - Qt/GTK theming"
echo " 9) nvidia(developing) - NVIDIA drivers (only if you have an NVIDIA GPU)"
echo ""
echo " a) ALL - Install everything (except nvidia)"
echo " n) ALL+NVIDIA - Install everything (including nvidia)"
echo " q) QUIT - Exit"
echo ""
}
get_selection() {
local SELECTED=()
while true; do
show_menu
echo -ne "${BLUE}Select numbers or letters separated by spaces: ${NC}"
read -r input
case "$input" in
q | Q)
log_info "Installation cancelled."
exit 0
;;
a | A)
SELECTED=("core" "terminal" "editor" "apps" "utils" "fonts" "quickshell" "theming")
break
;;
n | N)
SELECTED=("core" "terminal" "editor" "apps" "utils" "fonts" "quickshell" "theming" "nvidia")
break
;;
*)
for num in $input; do
case "$num" in
1) SELECTED+=("core") ;;
2) SELECTED+=("terminal") ;;
3) SELECTED+=("editor") ;;
4) SELECTED+=("apps") ;;
5) SELECTED+=("utils") ;;
6) SELECTED+=("fonts") ;;
7) SELECTED+=("quickshell") ;;
8) SELECTED+=("theming") ;;
9) SELECTED+=("nvidia") ;;
*) log_warn "Invalid option: $num" ;;
esac
done
if [[ ${#SELECTED[@]} -gt 0 ]]; then
break
fi
;;
esac
done
# Remove duplicates
CATEGORIES=($(printf "%s\n" "${SELECTED[@]}" | sort -u))
}
# =============================================================================
# Setup functions
# =============================================================================
run_stow() {
log_header "Creating Symlinks (Stow)"
source "$SETUP_DIR/stow.sh"
run_stow_main
}
run_hyprland_setup() {
log_header "Configuring Hyprland"
source "$SETUP_DIR/hyprland.sh"
run_hyprland_main
}
setup_zsh() {
log_header "Configuring Zsh"
# Change default shell to zsh
if [[ "$SHELL" != *"zsh"* ]]; then
log_step "Changing default shell to Zsh..."
chsh -s $(which zsh)
log_info "Shell changed to Zsh. Log out/in to apply."
else
log_info "Zsh is already the default shell."
fi
# Install Oh-My-Zsh
local ZSH_DIR="$HOME/.oh-my-zsh"
if [[ ! -d "$ZSH_DIR" ]]; then
log_step "Installing Oh-My-Zsh..."
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$ZSH_DIR"
log_info "Oh-My-Zsh installed."
else
log_info "Oh-My-Zsh is already installed."
fi
# Install plugins and themes
local ZSH_CUSTOM_DIR="$ZSH_DIR/custom"
local ZSH_DEPS=(
"https://github.com/zsh-users/zsh-autosuggestions|plugins/zsh-autosuggestions"
"https://github.com/zsh-users/zsh-syntax-highlighting|plugins/zsh-syntax-highlighting"
"https://github.com/jeffreytse/zsh-vi-mode|plugins/zsh-vi-mode"
"https://github.com/romkatv/powerlevel10k|themes/powerlevel10k"
)
for item in "${ZSH_DEPS[@]}"; do
local URL="${item%%|*}"
local DEST="${item##*|}"
local NAME=$(basename "$DEST")
if [[ ! -d "$ZSH_CUSTOM_DIR/$DEST" ]]; then
log_step "Installing $NAME..."
git clone --depth=1 "$URL" "$ZSH_CUSTOM_DIR/$DEST"
log_info "$NAME installed."
else
log_info "$NAME is already installed."
fi
done
}
setup_tmux() {
log_header "Configuring Tmux"
# Install TPM (Tmux Plugin Manager)
local TPM_DIR="$HOME/.tmux/plugins/tpm"
if [[ ! -d "$TPM_DIR" ]]; then
log_step "Installing TPM (Tmux Plugin Manager)..."
git clone https://github.com/tmux-plugins/tpm "$TPM_DIR"
log_info "TPM installed. Use prefix + I inside tmux to install plugins."
else
log_info "TPM is already installed."
fi
}
setup_services() {
log_header "Enabling Services"
# Bluetooth
if systemctl list-unit-files | grep -q "bluetooth.service"; then
log_step "Enabling Bluetooth..."
sudo systemctl enable --now bluetooth.service
fi
# NetworkManager
if systemctl list-unit-files | grep -q "NetworkManager.service"; then
log_step "Enabling NetworkManager..."
sudo systemctl enable --now NetworkManager.service
fi
}
setup_mimetypes() {
log_header "Configuring Default Applications (MIME)"
if command -v dolphin &>/dev/null; then
log_step "Setting Dolphin as default file manager..."
# Set Dolphin to open directories
xdg-mime default org.kde.dolphin.desktop inode/directory
# Update KDE services database
if command -v kbuildsycoca6 &>/dev/null; then
log_step "Updating KDE services cache..."
kbuildsycoca6 >/dev/null 2>&1
fi
else
log_warn "Dolphin not found. Skipping MIME types configuration."
fi
}
setup_wallpaper() {
log_header "Configuring Initial Wallpaper"
local CURRENT_FILE="$HOME/.local/wallpapers/.current"
local WALLPAPER
if [[ -f "$CURRENT_FILE" ]]; then
WALLPAPER="$(cat "$CURRENT_FILE")"
fi
# Fallback to default if .current doesn't exist or points to a missing file
if [[ -z "$WALLPAPER" || ! -f "$WALLPAPER" ]]; then
WALLPAPER="$HOME/.local/wallpapers/water.png"
fi
# Check if awww is installed
if ! command -v awww &>/dev/null; then
log_warn "awww is not installed. Skipping wallpaper configuration."
return 0
fi
# Check if the wallpaper exists
if [[ ! -f "$WALLPAPER" ]]; then
log_warn "Wallpaper not found: $WALLPAPER"
return 0
fi
# Check if running in a Wayland session
if [[ -z "$WAYLAND_DISPLAY" ]]; then
log_warn "Not in a Wayland session."
log_info "The wallpaper will be applied automatically when Hyprland starts."
return 0
fi
log_step "Starting awww daemon..."
# Start daemon if not running
if ! pgrep -f "awww-daemon" &>/dev/null; then
awww-daemon >/dev/null 2>&1 &
fi
sleep 3
# Check if daemon started
if ! pgrep -f "awww-daemon" &>/dev/null; then
log_warn "Could not start awww daemon."
return 0
fi
log_step "Applying wallpaper"
if awww img "$WALLPAPER" --transition-type grow --transition-duration 2 2>/dev/null; then
log_info "Wallpaper configured successfully!"
else
log_warn "Failed to apply wallpaper."
fi
}
setup_migrations() {
log_header "Initializing Lyne CLI"
local MIGRATIONS_DIR="$DOTFILES_DIR/.data/lyne-cli/migrations"
local DONE_FILE="$HOME/.local/share/lyne/migrations-done"
mkdir -p "$(dirname "$DONE_FILE")"
touch "$DONE_FILE"
# Mark all current migrations as done (fresh installs don't need them)
local count=0
for migration in "$MIGRATIONS_DIR"/*.sh; do
[[ -f "$migration" ]] || continue
local name
name="$(basename "$migration")"
if ! grep -qxF "$name" "$DONE_FILE" 2>/dev/null; then
echo "$name" >>"$DONE_FILE"
((count++)) || true
fi
done
log_info "Marked $count migrations as done (fresh install)"
}
setup_state_aur_helper() {
local STATE_FILE="$HOME/.config/quickshell/state.json"
if [[ ! -f "$STATE_FILE" ]]; then
log_warn "state.json not found. Skipping AUR helper configuration."
return 0
fi
if ! command -v jq &>/dev/null; then
log_warn "jq not found. Skipping AUR helper configuration."
return 0
fi
log_step "Setting AUR helper in state.json..."
local TEMP_FILE
TEMP_FILE=$(mktemp)
jq --arg helper "$AUR_HELPER" '.system.aurHelper = $helper' "$STATE_FILE" >"$TEMP_FILE" && mv "$TEMP_FILE" "$STATE_FILE"
log_info "AUR helper set to: $AUR_HELPER"
}
# =============================================================================
# Full installation
# =============================================================================
full_install() {
log_header "Starting Full Installation"
# Check internet and AUR helper now (after selection)
check_internet
check_aur_helper
# Install stow first
log_step "Installing GNU Stow..."
sudo pacman -S --needed --noconfirm stow git
# Install selected packages
for category in "${CATEGORIES[@]}"; do
log_header "Installing: ${category^^}"
install_packages "$category"
done
# Run setup scripts
run_stow
run_hyprland_setup
setup_state_aur_helper
setup_mimetypes
# Install Tela icons from git (if fonts was selected)
if [[ " ${CATEGORIES[*]} " =~ " fonts " ]]; then
log_header "Installing Tela Icon Theme"
install_tela_icons
fi
# Additional setup based on installed categories
if [[ " ${CATEGORIES[*]} " =~ " terminal " ]]; then
setup_zsh
setup_tmux
fi
# Enable services
if [[ " ${CATEGORIES[*]} " =~ " utils " ]]; then
setup_services
fi
# Configure initial wallpaper
if [[ " ${CATEGORIES[*]} " =~ " core " ]]; then
setup_wallpaper
fi
# Apply GTK theme
if [[ " ${CATEGORIES[*]} " =~ " theming " ]]; then
setup_theming
fi
# Mark all existing migrations as done (fresh install)
setup_migrations
}
# =============================================================================
# Reboot prompt
# =============================================================================
ask_reboot() {
echo ""
echo -ne "${YELLOW}Do you want to reboot the system now to apply all changes? [Y/n]: ${NC}"
read -r do_reboot
if [[ $do_reboot =~ ^[Yy]$ ]] || [[ -z "$do_reboot" ]]; then
log_info "Rebooting..."
sleep 2
sudo reboot
else
log_info "Remember to reboot the system to apply all changes."
fi
}
# =============================================================================
# Final summary
# =============================================================================
show_summary() {
log_header "Installation Complete!"
echo -e "${GREEN}Installed categories:${NC}"
for cat in "${CATEGORIES[@]}"; do
echo " - $cat"
done
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo " 1. Log out and select 'Hyprland (uwsm)' in your display manager"
echo " 2. Or start manually with: uwsm start hyprland-uwsm.desktop"
echo ""
echo " 3. Configure your monitors with: nwg-displays"
echo " 4. Workspaces will be configured automatically by workspace-manager"
echo ""
if [[ " ${CATEGORIES[*]} " =~ " terminal " ]]; then
echo " 5. In tmux, use prefix + I to install plugins"
fi
if [[ " ${CATEGORIES[*]} " =~ " nvidia " ]]; then
echo ""
echo -e "${YELLOW}NVIDIA:${NC}"
echo " - Review ~/.config/hypr/local/extra_environment.lua"
echo " - For hybrid GPUs, uncomment the AQ_DRM_DEVICES line"
fi
echo ""
log_info "Enjoy your new setup!"
echo ""
}
# =============================================================================
# Show banner
# =============================================================================
show_banner() {
echo ""
echo -e "${CYAN}"
cat <<'EOF'
╔═══════════════════════════════════════════════════════════════╗
║ ║
║ █ █▄█ █▄ █ █▀▀ ▄▄ █▀▄ █▀█ ▀█▀ █▀ ║
║ █▄▄ █ █ ▀█ ██▄ █▄▀ █▄█ █ ▄█ ║
║ ║
║ https://github.com/caioax/lyne-dots ║
║ Installation Script ║
║ ║
╚═══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
}
# =============================================================================
# Main
# =============================================================================
main() {
show_banner
# Check if running on Arch Linux
check_arch
# FIRST: Category selection (before any installation)
get_selection
echo ""
log_info "Selected categories: ${CATEGORIES[*]}"
echo ""
echo -ne "${YELLOW}Continue with the installation? [Y/n]: ${NC}"
read -r confirm
if [[ $confirm =~ ^[Nn]$ ]]; then
log_info "Installation cancelled."
exit 0
fi
# Run installation (checks and AUR helper here)
full_install
# Show summary
show_summary
# Prompt for reboot
ask_reboot
}
# =============================================================================
# Command line arguments
# =============================================================================
case "${1:-}" in
--help | -h)
echo "Usage: ./install.sh [option]"
echo ""
echo "Options:"
echo " --help, -h Show this help"
echo " --stow-only Only run stow (symlinks)"
echo " --setup-only Only run Hyprland setup"
echo " --packages PKG Install only the specified category"
echo ""
echo "Available categories:"
echo " core, terminal, editor, apps, utils, fonts, quickshell, theming, nvidia"
exit 0
;;
--stow-only)
check_arch
sudo pacman -S --needed --noconfirm stow
source "$SETUP_DIR/stow.sh"
run_stow_main
exit 0
;;
--setup-only)
check_arch
source "$SETUP_DIR/hyprland.sh"
run_hyprland_main
exit 0
;;
--packages)
check_arch
check_internet
check_aur_helper
if [[ -z "${2:-}" ]]; then
log_error "Please specify a category!"
exit 1
fi
install_packages "$2"
exit 0
;;
*)
main
;;
esac