-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·855 lines (731 loc) · 26.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·855 lines (731 loc) · 26.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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
#!/usr/bin/env bash
#==============================================================================
# Dotfiles Installation Script
# Automated setup for Hyprland environment
#==============================================================================
set -euo pipefail # Exit on error, undefined vars, pipe failures
# Script directory
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly DOTFILES_DIR="${SCRIPT_DIR}"
readonly BACKUP_DIR="${HOME}/.dotfiles_backup_$(date +%Y%m%d_%H%M%S)"
readonly CONFIG_DIR="${HOME}/.config"
readonly LOG_FILE="${DOTFILES_DIR}/install.log"
# Colors for output
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m'
# Load package lists
if [[ ! -f "${DOTFILES_DIR}/lib/packages.conf" ]]; then
echo -e "${RED}✗${NC} lib/packages.conf not found in ${DOTFILES_DIR}"
exit 1
fi
source "${DOTFILES_DIR}/lib/packages.conf"
#==============================================================================
# Helper Functions
#==============================================================================
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" | tee -a "${LOG_FILE}"
}
print_header() {
echo -e "\n${BLUE}==>${NC} ${1}" | tee -a "${LOG_FILE}"
}
print_success() {
echo -e "${GREEN}✓${NC} ${1}" | tee -a "${LOG_FILE}"
}
print_warning() {
echo -e "${YELLOW}!${NC} ${1}" | tee -a "${LOG_FILE}"
}
print_error() {
echo -e "${RED}✗${NC} ${1}" | tee -a "${LOG_FILE}"
}
ask_confirmation() {
read -rp "$(echo -e "${YELLOW}?${NC}") ${1} (y/N): " response
[[ "${response}" =~ ^[Yy]$ ]]
}
# Install an optional tool via yay. Optionally runs a post-install hook
# (name of a shell function) after a successful install.
# Usage: install_optional_tool NAME "pkg1 pkg2" [post_hook_fn]
install_optional_tool() {
local name="$1"
local pkgs="$2"
local post_hook="${3:-}"
if ! command_exists yay; then
print_warning "yay not found, please install ${name} manually: yay -S ${pkgs}"
return 1
fi
# shellcheck disable=SC2086
if yay -S --noconfirm ${pkgs}; then
print_success "${name} installed successfully"
if [[ -n "${post_hook}" ]] && declare -F "${post_hook}" >/dev/null; then
"${post_hook}"
fi
return 0
fi
print_error "${name} installation failed"
return 1
}
cleanup() {
if [[ -n "${BACKUP_DIR:-}" ]] && [[ -d "${BACKUP_DIR}" ]]; then
if [[ -z "$(ls -A "${BACKUP_DIR}" 2>/dev/null)" ]]; then
rm -rf "${BACKUP_DIR}"
log "Removed empty backup directory"
fi
fi
}
error_exit() {
print_error "$1"
cleanup
exit 1
}
command_exists() {
command -v "$1" &> /dev/null
}
package_installed() {
pacman -Qi "$1" &> /dev/null
}
#==============================================================================
# Installation Steps
#==============================================================================
check_requirements() {
print_header "Checking requirements"
# Check if running from correct directory
if [[ ! -f "${DOTFILES_DIR}/install.sh" ]]; then
error_exit "Please run this script from the dotfiles directory"
fi
# Check if directories exist
if [[ ! -d "${DOTFILES_DIR}/config" ]]; then
error_exit "config/ directory not found in ${DOTFILES_DIR}"
fi
print_success "Requirements check passed"
}
check_arch() {
print_header "Checking system compatibility"
if [[ ! -f /etc/arch-release ]]; then
print_warning "This script is designed for Arch Linux"
if ! ask_confirmation "Continue anyway?"; then
exit 1
fi
fi
print_success "System check passed"
}
check_yay() {
print_header "Checking package manager"
if command_exists yay; then
print_success "yay is installed"
return 0
fi
print_warning "yay AUR helper not found"
if ! ask_confirmation "Install yay? (required for AUR packages)"; then
print_warning "Continuing without yay - some packages may not be available"
return 0
fi
# Install required dependencies for building yay
sudo pacman -S --needed --noconfirm base-devel git || {
print_error "Failed to install base-devel and git"
return 1
}
# Install yay
print_header "Installing yay"
local tmp_dir
tmp_dir=$(mktemp -d) || {
print_error "Failed to create temporary directory"
return 1
}
local original_dir="${PWD}"
if git clone https://aur.archlinux.org/yay.git "${tmp_dir}"; then
cd "${tmp_dir}" || {
rm -rf "${tmp_dir}"
return 1
}
if makepkg -si --noconfirm; then
print_success "yay installed successfully"
cd "${original_dir}" || true
rm -rf "${tmp_dir}"
return 0
else
print_error "Failed to build yay"
cd "${original_dir}" || true
rm -rf "${tmp_dir}"
return 1
fi
else
print_error "Failed to clone yay repository"
rm -rf "${tmp_dir}"
return 1
fi
}
check_dependencies() {
print_header "Checking dependencies"
local -a missing=()
for pkg in "${CORE_PACKAGES[@]}"; do
if ! package_installed "${pkg}"; then
missing+=("${pkg}")
fi
done
if [[ ${#missing[@]} -gt 0 ]]; then
print_warning "Missing core dependencies: ${missing[*]}"
echo ""
if command_exists yay; then
if ask_confirmation "Install missing dependencies automatically?"; then
print_header "Installing dependencies"
if yay -S --needed --noconfirm "${missing[@]}"; then
print_success "All dependencies installed successfully"
else
print_error "Failed to install some dependencies"
if ! ask_confirmation "Continue anyway?"; then
exit 1
fi
fi
else
echo "Install manually with:"
echo " yay -S ${missing[*]}"
echo ""
if ! ask_confirmation "Continue without installing dependencies?"; then
exit 1
fi
fi
else
print_warning "yay not found. Please install dependencies manually:"
for pkg in "${missing[@]}"; do
echo " yay -S ${pkg}"
done
echo ""
if ! ask_confirmation "Continue without installing dependencies?"; then
exit 1
fi
fi
else
print_success "All core dependencies installed"
fi
}
backup_existing_configs() {
print_header "Backing up existing configurations"
local backed_up=0
for config in "${CONFIGS[@]}"; do
local config_path="${CONFIG_DIR}/${config}"
if [[ -e "${config_path}" ]] || [[ -L "${config_path}" ]]; then
# Backup real files/directories, remove old symlinks
if [[ ! -L "${config_path}" ]]; then
mkdir -p "${BACKUP_DIR}"
if mv "${config_path}" "${BACKUP_DIR}/"; then
print_success "Backed up ${config}"
backed_up=1
else
print_warning "Failed to backup ${config}"
fi
else
# Remove old symlink
rm -f "${config_path}"
print_success "Removed old symlink ${config}"
fi
fi
done
# Backup or remove home directory files
for file in "${HOME_FILES[@]}"; do
local file_path="${HOME}/${file}"
if [[ -e "${file_path}" ]] || [[ -L "${file_path}" ]]; then
if [[ ! -L "${file_path}" ]]; then
mkdir -p "${BACKUP_DIR}"
if mv "${file_path}" "${BACKUP_DIR}/"; then
print_success "Backed up ${file}"
backed_up=1
else
print_warning "Failed to backup ${file}"
fi
else
# Remove old symlink
rm -f "${file_path}"
print_success "Removed old symlink ${file}"
fi
fi
done
if [[ ${backed_up} -eq 1 ]]; then
print_success "Backups saved to: ${BACKUP_DIR}"
else
print_success "No existing configs to backup"
fi
}
create_symlinks() {
print_header "Creating symlinks"
# Ensure config directory exists
mkdir -p "${CONFIG_DIR}"
# Config symlinks
for config in "${CONFIGS[@]}"; do
local source="${DOTFILES_DIR}/config/${config}"
local target="${CONFIG_DIR}/${config}"
if [[ -e "${source}" ]]; then
# Use -n flag to prevent creating symlink inside existing directory symlink
ln -sfn "${source}" "${target}"
print_success "Linked ${config}"
else
print_warning "Skipped ${config} (source not found)"
fi
done
# Home directory symlinks
for file in "${HOME_FILES[@]}"; do
local source="${DOTFILES_DIR}/home/${file}"
local target="${HOME}/${file}"
if [[ -e "${source}" ]]; then
ln -sfn "${source}" "${target}"
print_success "Linked ${file}"
else
print_warning "Skipped ${file} (source not found)"
fi
done
print_success "All symlinks created"
}
setup_local_config() {
print_header "Setting up device-specific configuration"
local local_conf="${CONFIG_DIR}/hypr/conf/local.conf"
local example_conf="${CONFIG_DIR}/hypr/conf/local.conf.example"
if [[ ! -f "${local_conf}" ]]; then
if [[ -f "${example_conf}" ]]; then
mv "${example_conf}" "${local_conf}"
print_success "Created local.conf from example"
print_warning "Edit ~/.config/hypr/conf/local.conf to customize:"
echo " • Add COINMARKETCAP_API_KEY for waybar-crypto"
echo " • Uncomment hyprsplit config for desktop setup"
else
print_warning "local.conf.example not found, skipping"
fi
else
print_success "local.conf already exists"
fi
}
setup_wallpaper_dir() {
print_header "Setting up wallpaper directory"
local wallpaper_dir="${HOME}/wallpaper"
mkdir -p "${wallpaper_dir}"
# Check if wallpapers already exist
local existing_count
existing_count=$(find "${wallpaper_dir}" -type f \( -name "*.jpg" -o -name "*.png" \) 2>/dev/null | wc -l)
if [[ ${existing_count} -gt 0 ]]; then
print_success "~/wallpaper directory contains ${existing_count} wallpaper(s)"
return 0
fi
print_success "Created ~/wallpaper directory"
local copied=0
# Try to copy from Hyprland
if [[ -d "/usr/share/hypr" ]]; then
shopt -s nullglob
for wallpaper in /usr/share/hypr/wall*.png /usr/share/hypr/wall*.jpg; do
if [[ -f "${wallpaper}" ]]; then
if cp "${wallpaper}" "${wallpaper_dir}/" 2>/dev/null; then
print_success "Copied $(basename "${wallpaper}") from Hyprland"
copied=1
fi
fi
done
shopt -u nullglob
fi
# Try system backgrounds if nothing copied yet
if [[ ${copied} -eq 0 ]] && [[ -d "/usr/share/backgrounds" ]]; then
shopt -s nullglob
for wallpaper in /usr/share/backgrounds/*.png /usr/share/backgrounds/*.jpg; do
if [[ -f "${wallpaper}" ]]; then
if cp "${wallpaper}" "${wallpaper_dir}/" 2>/dev/null; then
print_success "Copied $(basename "${wallpaper}") from system backgrounds"
copied=1
break
fi
fi
done
shopt -u nullglob
fi
# Download default wallpaper if nothing was copied
if [[ ${copied} -eq 0 ]]; then
print_warning "No local wallpapers found, downloading default wallpaper..."
if command_exists curl; then
# Download a simple default wallpaper (Hyprland's default from GitHub)
if curl -L -o "${wallpaper_dir}/default.png" \
"https://raw.githubusercontent.com/hyprwm/Hyprland/main/assets/wall_8K.png" 2>/dev/null; then
print_success "Downloaded default wallpaper"
copied=1
else
print_warning "Failed to download default wallpaper"
fi
elif command_exists wget; then
if wget -q -O "${wallpaper_dir}/default.png" \
"https://raw.githubusercontent.com/hyprwm/Hyprland/main/assets/wall_8K.png" 2>/dev/null; then
print_success "Downloaded default wallpaper"
copied=1
else
print_warning "Failed to download default wallpaper"
fi
fi
fi
# Final check
if [[ ${copied} -eq 0 ]]; then
print_error "No wallpapers available in ~/wallpaper"
print_warning "Please manually add at least one wallpaper (PNG or JPG) to ~/wallpaper"
print_warning "This is required for color scheme generation"
if ! ask_confirmation "Continue installation without wallpaper?"; then
error_exit "Installation cancelled - wallpaper required"
fi
fi
}
setup_sddm() {
print_header "Setting up SDDM"
if ! command_exists sddm; then
print_warning "SDDM not installed, skipping"
return 0
fi
if ask_confirmation "Configure SDDM with Silent theme?"; then
# Check sudo access
if ! sudo -v; then
print_error "Failed to get sudo access"
return 1
fi
# Install SDDM config as drop-in so it overrides distro defaults
# (SDDM reads /etc/sddm.conf.d/*.conf AFTER /etc/sddm.conf, so the
# drop-in wins over things like kde_settings.conf that ship with
# sddm-kcm and force Current=breeze).
sudo install -Dm644 "${DOTFILES_DIR}/config/sddm/sddm.conf" \
/etc/sddm.conf.d/10-dotfiles.conf \
|| print_warning "Failed to install SDDM config"
print_success "SDDM config installed to /etc/sddm.conf.d/10-dotfiles.conf"
# Check if Silent theme exists
if [[ -d "/usr/share/sddm/themes/silent" ]]; then
print_success "Silent theme found"
else
print_warning "Silent theme not found at /usr/share/sddm/themes/silent"
echo "Install with: yay -S sddm-silent-theme"
fi
# Enable SDDM
if ask_confirmation "Enable SDDM service?"; then
sudo systemctl enable sddm || print_warning "Failed to enable SDDM"
print_success "SDDM enabled"
fi
fi
}
install_shell_plugins() {
print_header "Checking shell plugins"
local -a shell_plugins=(
"starship"
"zsh-autosuggestions"
"zsh-syntax-highlighting"
"zsh-history-substring-search"
)
local -a missing_plugins=()
for plugin in "${shell_plugins[@]}"; do
if package_installed "${plugin}"; then
print_success "${plugin} already installed"
else
missing_plugins+=("${plugin}")
fi
done
if [[ ${#missing_plugins[@]} -gt 0 ]]; then
print_warning "Missing shell plugins: ${missing_plugins[*]}"
if command_exists yay; then
if ask_confirmation "Install missing shell plugins?"; then
yay -S --needed --noconfirm "${missing_plugins[@]}" || {
print_warning "Some shell plugins failed to install"
}
fi
else
print_warning "yay not found, install manually: yay -S ${missing_plugins[*]}"
fi
fi
}
install_optional_packages() {
print_header "Installing optional packages"
if ! command_exists yay; then
print_warning "yay not found, skipping optional packages"
return 0
fi
local -a missing=()
local -a already_installed=()
for pkg in "${OPTIONAL_PACKAGES[@]}"; do
if ! package_installed "${pkg}"; then
missing+=("${pkg}")
else
already_installed+=("${pkg}")
fi
done
if [[ ${#already_installed[@]} -gt 0 ]]; then
print_success "${#already_installed[@]} optional packages already installed"
fi
if [[ ${#missing[@]} -eq 0 ]]; then
print_success "All optional packages already installed"
return 0
fi
echo ""
echo "Missing optional packages (${#missing[@]}):"
for pkg in "${missing[@]}"; do
echo " • ${pkg}"
done
echo ""
if ask_confirmation "Install all missing optional packages?"; then
if yay -S --needed --noconfirm "${missing[@]}"; then
print_success "Optional packages installed successfully"
else
print_warning "Some optional packages failed to install"
fi
else
print_warning "Skipped optional packages installation"
echo "Install manually with: yay -S ${missing[*]}"
fi
}
install_optional_components() {
print_header "Optional components installation"
echo ""
echo "The following components are optional and can enhance your workflow:"
echo ""
# Miniconda
if [[ ! -f "${HOME}/miniconda3/bin/conda" ]]; then
if ask_confirmation "Install Miniconda? (Python package manager)"; then
print_header "Installing Miniconda"
local tmp_dir
tmp_dir=$(mktemp -d) || {
print_error "Failed to create temporary directory"
return 1
}
local miniconda_url="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
local installer="${tmp_dir}/miniconda.sh"
# Download installer and published SHA256
if ! curl -fsSL -o "${installer}" "${miniconda_url}"; then
print_error "Failed to download Miniconda installer"
rm -rf "${tmp_dir}"
return 1
fi
if ! curl -fsSL -o "${installer}.sha256" "${miniconda_url}.sha256"; then
print_error "Failed to download Miniconda checksum"
rm -rf "${tmp_dir}"
return 1
fi
# Verify checksum (file format: "<hash> Miniconda3-latest-Linux-x86_64.sh")
local expected_sum actual_sum
expected_sum=$(awk '{print $1}' "${installer}.sha256")
actual_sum=$(sha256sum "${installer}" | awk '{print $1}')
if [[ "${expected_sum}" != "${actual_sum}" ]]; then
print_error "Miniconda checksum mismatch"
print_error " expected: ${expected_sum}"
print_error " actual: ${actual_sum}"
rm -rf "${tmp_dir}"
return 1
fi
print_success "Miniconda checksum verified"
if bash "${installer}" -b -p "${HOME}/miniconda3"; then
print_success "Miniconda installed to ~/miniconda3"
print_success "conda.zsh will auto-detect ~/miniconda3"
else
print_error "Miniconda installation failed"
fi
rm -rf "${tmp_dir}"
fi
else
print_success "Miniconda already installed"
fi
# Go
if ! command_exists go; then
if ask_confirmation "Install Go? (yay -S go)"; then
install_optional_tool "Go" "go"
fi
else
print_success "Go already installed"
fi
# Docker
docker_post_install() {
if ask_confirmation "Add current user to docker group?"; then
if sudo usermod -aG docker "${USER}"; then
print_success "User added to docker group"
print_warning "Logout and login again for group changes to take effect"
else
print_error "Failed to add user to docker group"
fi
fi
if ask_confirmation "Enable Docker service?"; then
if sudo systemctl enable docker; then
print_success "Docker service enabled"
else
print_error "Failed to enable Docker service"
fi
fi
}
if ! command_exists docker; then
if ask_confirmation "Install Docker? (yay -S docker docker-compose)"; then
install_optional_tool "Docker" "docker docker-compose" docker_post_install
fi
else
print_success "Docker already installed"
fi
# Node.js/npm
if ! command_exists node; then
if ask_confirmation "Install Node.js? (yay -S nodejs npm)"; then
install_optional_tool "Node.js" "nodejs npm"
fi
else
print_success "Node.js already installed"
fi
echo ""
print_success "Optional components setup complete"
}
generate_initial_colors() {
print_header "Generating initial color scheme"
if ! command_exists matugen; then
print_warning "Matugen not installed, skipping"
return 0
fi
# Pick a random wallpaper from ~/wallpaper
local wallpaper
wallpaper=$(find "${HOME}/wallpaper" -type f \( -name "*.jpg" -o -name "*.png" \) 2>/dev/null | shuf -n 1)
if [[ -z "${wallpaper}" ]]; then
print_warning "No wallpapers found in ~/wallpaper, skipping"
return 0
fi
mkdir -p "${HOME}/.cache"
echo "${wallpaper}" > "${HOME}/.cache/current_wallpaper"
# Generate colors
matugen image "${wallpaper}" --type scheme-content || print_warning "Matugen color generation failed"
print_success "Generated colors from ${wallpaper##*/}"
# Generate rasi file for rofi background
local blurred="${HOME}/.cache/blurred_wallpaper.png"
if command_exists magick; then
magick "${wallpaper}" -filter box -quality 85 -resize 75% -blur 50x30 "${blurred}" 2>/dev/null
else
cp "${wallpaper}" "${blurred}"
fi
echo "* { current-image: url(\"${blurred}\", height); }" > "${HOME}/.cache/current_wallpaper.rasi"
# Apply wallpaper if Hyprland is running
if [[ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]]; then
if command_exists awww; then
# Ensure awww-daemon is running
if ! pgrep -x awww-daemon > /dev/null; then
awww-daemon > /dev/null 2>&1 &
disown
sleep 1
fi
awww img "${wallpaper}" --transition-type fade --transition-duration 1 2>/dev/null \
&& print_success "Wallpaper applied via awww"
elif command_exists hyprpaper; then
local hyprpaper_conf="${HOME}/.config/hypr/hyprpaper.conf"
cat > "${hyprpaper_conf}" <<EOF
preload = ${wallpaper}
wallpaper = ,${wallpaper}
splash = false
EOF
killall hyprpaper 2>/dev/null
hyprpaper &
disown
print_success "Wallpaper applied via hyprpaper"
else
print_warning "No wallpaper engine found (awww or hyprpaper)"
fi
fi
}
setup_icons() {
print_header "Setting up icon theme"
if ! command_exists papirus-folders; then
if command_exists yay; then
yay -S --needed --noconfirm papirus-folders-git \
|| { print_warning "Failed to install papirus-folders"; return 0; }
else
print_warning "yay not found, skipping papirus-folders"
return 0
fi
fi
papirus-folders -C black --theme Papirus-Dark \
&& print_success "Papirus-Dark folder color set to black" \
|| print_warning "papirus-folders failed"
}
generate_gtk_bookmarks() {
print_header "Generating GTK bookmarks"
if [[ -f "${DOTFILES_DIR}/scripts/generate-bookmarks.sh" ]]; then
bash "${DOTFILES_DIR}/scripts/generate-bookmarks.sh" || print_warning "Failed to generate bookmarks"
print_success "GTK bookmarks generated"
else
print_warning "generate-bookmarks.sh not found, skipping"
fi
}
set_default_shell() {
print_header "Setting default shell"
local zsh_path
zsh_path=$(command -v zsh) || {
print_warning "zsh not found"
return 0
}
if [[ "${SHELL}" != "${zsh_path}" ]]; then
if ask_confirmation "Set zsh as default shell?"; then
chsh -s "${zsh_path}" || print_warning "Failed to change shell"
print_success "Default shell changed to zsh"
print_warning "Logout and login again for changes to take effect"
fi
else
print_success "Zsh already set as default shell"
fi
}
#==============================================================================
# Main Installation
#==============================================================================
main() {
# Set up error handling
trap cleanup EXIT
trap 'error_exit "Script interrupted"' INT TERM
# Start logging
log "Installation started"
clear
echo ""
echo "╔═══════════════════════════════════════╗"
echo "║ Dotfiles Installation Script ║"
echo "║ Hyprland + Waybar + Rofi + More ║"
echo "╚═══════════════════════════════════════╝"
echo ""
# Confirmation
echo "This script will:"
echo " • Backup existing configs to ${BACKUP_DIR}"
echo " • Create symlinks from ${DOTFILES_DIR} to ~/.config/"
echo " • Set up SDDM (optional)"
echo " • Install shell plugins (optional)"
echo " • Install optional components: Miniconda, Go, Docker, Node.js (optional)"
echo " • Generate initial color scheme"
echo ""
echo "Installation log: ${LOG_FILE}"
echo ""
if ! ask_confirmation "Continue with installation?"; then
echo "Installation cancelled"
exit 0
fi
# Run installation steps
check_requirements
check_arch
check_yay
check_dependencies
backup_existing_configs
create_symlinks
setup_local_config
setup_wallpaper_dir
install_shell_plugins
install_optional_packages
setup_sddm
install_optional_components
setup_icons
generate_initial_colors
generate_gtk_bookmarks
set_default_shell
# Reload Hyprland and launch services if running
if command_exists hyprctl && [[ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]]; then
hyprctl reload && print_success "Hyprland config reloaded"
# Launch waybar if not running
if ! pgrep -x waybar > /dev/null; then
"${DOTFILES_DIR}/config/waybar/launch.sh" &
disown
print_success "Waybar launched"
fi
fi
# Done
print_header "Installation Complete!"
echo ""
echo "Next steps:"
echo " 1. Change wallpaper: Super + Ctrl + W"
echo " 2. If not in Hyprland: logout and select 'Hyprland' session"
echo " 3. If you have any problems: logout or reboot and login again"
echo ""
echo "Installation log saved to: ${LOG_FILE}"
echo ""
print_success "Enjoy your new setup!"
log "Installation completed successfully"
}
# Run main function
main "$@"