-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilder
More file actions
executable file
·164 lines (129 loc) · 4.04 KB
/
Builder
File metadata and controls
executable file
·164 lines (129 loc) · 4.04 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
#!/bin/bash
set -e
# Arch Dotfiles Builder
# Advanced installation with dependency management
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="${SCRIPT_DIR}/install.log"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() {
echo -e "${GREEN}[*]${NC} $1" | tee -a "$LOG_FILE"
}
error() {
echo -e "${RED}[!]${NC} $1" | tee -a "$LOG_FILE"
}
warn() {
echo -e "${YELLOW}[!]${NC} $1" | tee -a "$LOG_FILE"
}
check_cmd() {
if command -v "$1" &> /dev/null; then
log "$1 found"
return 0
else
warn "$1 not found"
return 1
fi
}
install_dependencies() {
log "Checking dependencies..."
local missing=()
for cmd in hyprland hyprlock kitty waybar; do
if ! check_cmd "$cmd"; then
missing+=("$cmd")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
error "Missing packages: ${missing[*]}"
# Suggest package manager based on system
if command -v pacman &>/dev/null; then
error "Install with: sudo pacman -S ${missing[*]}"
elif command -v apt &>/dev/null; then
error "Install with: sudo apt install ${missing[*]}"
elif command -v dnf &>/dev/null; then
error "Install with: sudo dnf install ${missing[*]}"
elif command -v zypper &>/dev/null; then
error "Install with: sudo zypper install ${missing[*]}"
elif command -v apk &>/dev/null; then
error "Install with: sudo apk add ${missing[*]}"
else
error "Please install missing packages using your distro's package manager"
fi
return 1
fi
log "All dependencies found"
return 0
}
backup_config() {
local config_dir="$HOME/.config"
local backup_dir="$config_dir/backup-$(date +%Y%m%d-%H%M%S)"
log "Backing up existing configs to $backup_dir..."
mkdir -p "$backup_dir"
for dir in hypr kitty vim waybar; do
if [ -d "$config_dir/$dir" ]; then
cp -r "$config_dir/$dir" "$backup_dir/"
log "Backed up $dir"
fi
done
}
install_configs() {
log "Installing configurations..."
local src_dir="$SCRIPT_DIR/home"
local home_dir="$HOME"
mkdir -p "$home_dir/.config"
# Copy .config contents
if [ -d "$src_dir/.config" ]; then
cp -rv "$src_dir/.config"/* "$home_dir/.config/" | tee -a "$LOG_FILE"
fi
# Copy root dotfiles
for file in "$src_dir"/.*; do
filename=$(basename "$file")
# Skip .git, .config, and . ..
if [[ "$filename" == ".git"* ]] || [[ "$filename" == ".config" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".." ]]; then
continue
fi
log "Installing $filename..."
cp -v "$file" "$home_dir/$filename" | tee -a "$LOG_FILE"
done
log "Installation complete!"
}
setup_shell() {
log "Configuring shell..."
if ! check_cmd zsh; then
warn "zsh not installed, skipping shell setup"
return
fi
if grep -q "/bin/zsh" /etc/shells 2>/dev/null; then
log "zsh already in /etc/shells"
else
warn "zsh not in /etc/shells, run: chsh -s /bin/zsh"
fi
}
main() {
echo "========================================="
echo "Arch Dotfiles Builder"
echo "========================================="
# Check if running as root (not recommended)
if [ "$EUID" -eq 0 ]; then
warn "Running as root - some configs may have permission issues"
fi
# Install dependencies
if ! install_dependencies; then
error "Dependency check failed"
exit 1
fi
# Backup existing configs
backup_config
# Install configs
install_configs
# Setup shell
setup_shell
log "========================================="
log "Installation successful!"
log "Reload Hyprland with: Super + Shift + R"
log "Full logs available in: $LOG_FILE"
log "========================================="
}
main "$@"