-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·242 lines (200 loc) · 5.75 KB
/
install.sh
File metadata and controls
executable file
·242 lines (200 loc) · 5.75 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
#!/bin/bash
set -e
# ANSI color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
BOLD='\033[1m'
DIM='\033[2m'
RESET='\033[0m'
# Status symbols
CHECK="✓"
CROSS="✗"
ARROW=">"
INFO="i"
# Config directories to process
folders=(
"cava"
"hypr"
"kitty"
"nvim"
"rofi"
"swaync"
"waybar"
"tmux"
)
# AUR packages
packages_to_install=(
"cava"
"kitty"
"neovim"
"rofi"
"swaync"
"waybar"
"fastfetch"
"zoxide"
"fzf"
"cmatrix"
"tmux"
)
error_exit() {
echo -e "\n${RED}${CROSS} Error: $1${RESET}" >&2
exit 1
}
# Progress bar with percentage
show_progress() {
local current=$1
local total=$2
local percentage=$((current * 100 / total))
local dots=$((current * 20 / total))
printf "\r${CYAN}Progress: ["
for ((i = 0; i < dots; i++)); do printf "#"; done
for ((i = dots; i < 20; i++)); do printf "."; done
printf "] ${WHITE}%d%% ${DIM}(%d/%d)${RESET}" $percentage $current $total
}
print_header() {
local title="$1"
echo -e "\n${BOLD}${BLUE}===========================================${RESET}"
echo -e "${BOLD}${WHITE} $title${RESET}"
echo -e "${BOLD}${BLUE}===========================================${RESET}"
}
print_success() {
echo -e "${GREEN}${CHECK} $1${RESET}"
}
print_warning() {
echo -e "${YELLOW}! $1${RESET}"
}
print_info() {
echo -e "${CYAN}${ARROW} $1${RESET}"
}
backup() {
print_header "Backing Up Configuration"
local total=${#folders[@]}
local current=0
for folder in "${folders[@]}"; do
current=$((current + 1))
show_progress $current $total
if [ -d "$HOME/.config/$folder" ]; then
mkdir -p "$HOME/backup"
cp -r "$HOME/.config/$folder" "$HOME/backup/" || error_exit "Failed to backup $folder"
echo -e "\n${GREEN}${CHECK} Backed up: $folder${RESET}"
else
echo -e "\n${YELLOW}! Folder $folder not found, skipping${RESET}"
fi
sleep 0.1
done
echo -e "\n"
print_info "Backing up .zshrc..."
if [ -f "$HOME/.zshrc" ]; then
mkdir -p "$HOME/backup"
cp "$HOME/.zshrc" "$HOME/backup/" || error_exit "Failed to backup .zshrc"
print_success "Backed up .zshrc"
else
print_warning ".zshrc not found, skipping"
fi
}
copy_folders() {
print_header "Installing Configurations"
local total=${#folders[@]}
local current=0
for folder in "${folders[@]}"; do
current=$((current + 1))
show_progress $current $total
if [ -d "$PWD/$folder" ]; then
mkdir -p "$HOME/.config/$folder"
cp -r "$PWD/$folder/." "$HOME/.config/$folder/" || error_exit "Failed to install $folder"
echo -e "\n${GREEN}${CHECK} Installed: $folder${RESET}"
else
echo -e "\n${YELLOW}! Source folder $folder not found, skipping${RESET}"
fi
sleep 0.1
done
# Handle .zshrc installation
print_info "Installing .zshrc..."
if [ -f "$PWD/.zshrc" ]; then
# Remove existing .zshrc if it exists
[ -f "$HOME/.zshrc" ] && rm "$HOME/.zshrc"
# Copy the zshrc from dotfiles to user's home directory
cp "$PWD/.zshrc" "$HOME/.zshrc" || error_exit "Failed to install .zshrc"
print_success "Installed .zshrc"
# Source the new .zshrc
print_info "Sourcing .zshrc..."
source "$HOME/.zshrc" || print_warning "Failed to source .zshrc (this is normal in some cases)"
else
print_warning ".zshrc not found in dotfiles, skipping"
fi
echo
}
install_packages() {
print_header "Installing Packages"
if ! command -v yay &>/dev/null; then
echo -e "${RED}${CROSS} yay not found. Please install yay first.${RESET}"
return 1
fi
local total=${#packages_to_install[@]}
local current=0
local installed=0
local skipped=0
for package in "${packages_to_install[@]}"; do
current=$((current + 1))
show_progress $current $total
if yay -Qq "$package" &>/dev/null; then
echo -e "\n${YELLOW}! $package already installed${RESET}"
skipped=$((skipped + 1))
else
echo -e "\n${CYAN}${ARROW} Installing $package...${RESET}"
if yay -S --noconfirm "$package"; then
print_success "$package installed"
installed=$((installed + 1))
else
echo -e "${RED}${CROSS} Failed to install $package${RESET}"
fi
fi
sleep 0.1
done
echo -e "\n${CYAN}${INFO} Summary: ${GREEN}$installed installed${RESET}, ${YELLOW}$skipped skipped${RESET}"
}
main() {
clear
echo -e "${BOLD}${PURPLE}"
echo "==========================================="
echo " Fadilix Hyprland Configuration Installer"
echo " https://github.com/Fadilix"
echo "==========================================="
echo -e "${RESET}"
echo -e "${DIM}This will backup existing configs and install new ones${RESET}\n"
echo -e "${BOLD}${WHITE}Configuration folders:${RESET}"
for folder in "${folders[@]}"; do
echo -e " ${CYAN}${ARROW}${RESET} $folder"
done
echo -e "\n${BOLD}${WHITE}Packages to install (${#packages_to_install[@]} total):${RESET}"
for package in "${packages_to_install[@]}"; do
echo -e " ${CYAN}${ARROW}${RESET} $package"
done
echo -e "\n${BOLD}${YELLOW}! Warning: This will backup and replace your configs!${RESET}"
echo -e "${WHITE}Continue? ${DIM}(y/N):${RESET} "
read -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Installation cancelled${RESET}"
exit 0
fi
echo -e "\n${GREEN}${CHECK} Starting installation...${RESET}"
backup
copy_folders
install_packages
print_header "Finalizing Setup"
print_info "Running refresh script..."
~/.config/hypr/scripts/Refresh.sh
echo -e "\n${BOLD}${GREEN}"
echo "==========================================="
echo " Installation Complete!"
echo "==========================================="
echo -e "${RESET}"
echo -e "${GREEN}${CHECK} All done! Please close the terminal!${RESET}\n"
}
main