-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharch-mod.sh
More file actions
executable file
·290 lines (260 loc) · 9.21 KB
/
arch-mod.sh
File metadata and controls
executable file
·290 lines (260 loc) · 9.21 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
#!/bin/bash
# GitHub.com/PiercingXX
# Color definitions
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check/install gum if missing
if ! command -v gum &> /dev/null; then
echo "gum not found. Installing..."
if command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm gum
else
echo "Please install gum manually."
exit 1
fi
fi
# Check if running as root. If root, script will exit
if [[ $EUID -eq 0 ]]; then
echo "This script should not be executed as root! Exiting......."
exit 1
fi
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to cache sudo credentials
cache_sudo_credentials() {
echo "Caching sudo credentials for script execution..."
sudo -v
# Keep sudo credentials fresh for the duration of the script
(while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &)
}
# Function to install bashrc support (placeholder - extend as needed)
install_bashrc_support() {
# This function ensures bashrc configurations are properly loaded
# Add any bashrc initialization logic here
return 0
}
ensure_network_online() {
local state=""
if command_exists nmcli && state=$(nmcli -t -f STATE g 2>/dev/null); then
if [[ "$state" != connected ]]; then
echo "Network connectivity is required to continue."
echo "nmcli reports state: $state"
fi
else
echo "NetworkManager status unavailable, falling back to route/interface checks..."
fi
if ip route show default 2>/dev/null | grep -q '^default ' && ip -4 addr show up 2>/dev/null | grep -q "inet "; then
return 0
fi
if ! ip -4 addr show up 2>/dev/null | grep -q "inet "; then
echo "Network connectivity is required to continue."
exit 1
fi
if ! ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then
if ! ping -c 1 -W 1 1.1.1.1 >/dev/null 2>&1; then
echo "Network connectivity is required to continue."
exit 1
fi
fi
}
username=$(id -un)
builddir=$(pwd)
# Cache sudo credentials
cache_sudo_credentials
# Require network for installs/downloads
ensure_network_online
# Function to display a message box using gum
function msg_box() {
gum style --border double --margin "1 2" --padding "1 2" --foreground 212 "$1"
read -n 1 -s -r -p "Press any key to continue..."; echo
}
# Function to display menu using gum
function menu() {
local options=(
"Install Arch Mod"
"Window Managers"
"Optional Nvidia Drivers"
"Optional Surface Kernel"
"Reboot System"
"Exit"
)
printf "%s\n" "${options[@]}" | gum choose --header "Run Options In Order:" --cursor.foreground 212 --selected.foreground 212
}
ensure_piercing_dots_repo() {
if [ ! -d "piercing-dots/.git" ]; then
rm -rf piercing-dots
git clone --depth 1 https://github.com/Piercingxx/piercing-dots.git
fi
}
run_wm_install_script() {
local label="$1"
local script_name="$2"
echo -e "${YELLOW}Installing ${label}...${NC}" | tee -a /tmp/wm_install.log
cd scripts || exit
chmod u+x "$script_name"
if ! ./"$script_name" 2>&1 | tee -a /tmp/wm_install.log; then
cd "$builddir" || true
echo -e "${YELLOW}${label} install encountered errors — check /tmp/wm_install.log.${NC}" | tee -a /tmp/wm_install.log
return 1
fi
cd "$builddir" || exit
echo -e "${GREEN}${label} installed successfully!${NC}" | tee -a /tmp/wm_install.log
}
install_terminal_minimal_session() {
ensure_piercing_dots_repo
sudo bash "$(pwd)/piercing-dots/scripts/setup-terminal-session.sh"
}
window_manager_menu() {
local options=(
"Install Hyprland"
"Install Sway"
"Install i3"
"Install bspwm"
"Install BusyBox Profile"
"Install Terminal Minimal Session"
"Back"
)
local wm_choices
local wm_choice
while true; do
clear
echo -e "${BLUE}Window Manager Installer${NC}"
wm_choices=$(printf "%s\n" "${options[@]}" | gum choose --header "Choose one or more installs:" --cursor.foreground 212 --selected.foreground 212) || break
[ -n "$wm_choices" ] || break
if [ "$wm_choices" = "Back" ]; then
break
fi
wm_choice="$wm_choices"
case $wm_choice in
"Install Hyprland")
run_wm_install_script "Hyprland" "hyprland-install.sh"
;;
"Install Sway")
run_wm_install_script "Sway" "sway-install.sh"
;;
"Install i3")
run_wm_install_script "i3" "i3-install.sh"
;;
"Install bspwm")
run_wm_install_script "bspwm" "bspwm-install.sh"
;;
"Install BusyBox Profile")
run_wm_install_script "BusyBox Profile" "busybox-install.sh"
;;
"Install Terminal Minimal Session")
install_terminal_minimal_session
;;
esac
read -n 1 -s -r -p "Press any key to continue..."; echo
done
}
prompt_install_window_managers_after_install() {
if gum confirm "Install window managers before reboot?"; then
window_manager_menu
fi
}
# Main menu loop
while true; do
clear
echo -e "${BLUE}PiercingXX's Arch Mod Script${NC}"
echo -e "${GREEN}Welcome ${username}${NC}\n"
choice=$(menu)
case $choice in
"Install Arch Mod")
echo -e "${YELLOW}Installing Essentials...${NC}"
# Essentials
cd scripts || exit
chmod u+x step-1.sh
./step-1.sh
wait
cd "$builddir" || exit
# Install bash support
# Load user's bashrc
if [ -f "/home/$username/.bashrc" ]; then
. "/home/$username/.bashrc"
fi
install_bashrc_support
echo -e "${GREEN}Essentials Installed successfully!${NC}"
# Apply Piercing Rice
echo -e "${YELLOW}Applying PiercingXX Gnome Customizations...${NC}"
rm -rf piercing-dots
git clone --depth 1 https://github.com/Piercingxx/piercing-dots.git
cd piercing-dots || exit
chmod u+x install.sh
./install.sh
wait
cd "$builddir" || exit
# App install
echo -e "${YELLOW}Installing Core Applications...${NC}"
cd scripts || exit
chmod u+x apps.sh
./apps.sh
wait
cd "$builddir" || exit
echo -e "${GREEN}Core Apps Installed successfully!${NC}"
# Window managers now installed from dedicated menu option
echo -e "${YELLOW}Window manager install/style is now in the Window Managers menu option.${NC}"
# Enable Bluetooth again
sudo systemctl start bluetooth
sudo systemctl enable bluetooth
# Apply Piercing Gnome Customizations as User
cd piercing-dots/scripts || exit
./gnome-customizations.sh
wait
cd "$builddir" || exit
# Install Pop Shell
chmod u+x scripts/install-pop-shell.sh
./scripts/install-pop-shell.sh
wait
cd "$builddir" || exit
# Replace .bashrc
cp -f piercing-dots/resources/bash/.bashrc /home/"$username"/.bashrc
source "$HOME/.bashrc"
# Install Printers
chmod u+x scripts/install-printers.sh
./scripts/install-printers.sh
wait
cd "$builddir" || exit
# Clean Up
rm -rf piercing-dots
echo -e "${GREEN}PiercingXX Gnome Customizations Applied successfully!${NC}"
prompt_install_window_managers_after_install
msg_box "System will reboot now."
sudo reboot
;;
"Optional Nvidia Drivers")
echo -e "${YELLOW}Installing Nvidia Drivers...${NC}"
cd scripts || exit
chmod +x ./nvidia.sh
sudo ./nvidia.sh
cd "$builddir" || exit
;;
"Window Managers")
window_manager_menu
;;
"Optional Surface Kernel")
echo -e "${YELLOW}Microsoft Surface Kernel...${NC}"
# Copy systemd service file
sudo cp scripts/surface-kernel-setup.service /etc/systemd/system/
sudo install -m 755 scripts/surface-kernel-setup.sh /usr/local/bin/
sudo systemctl enable --now surface-kernel-setup.service
cd "$builddir" || exit
echo -e "${GREEN}Microsoft Kernel Installed.!${NC}"
;;
"Reboot System")
echo -e "${YELLOW}Rebooting system in 3 seconds...${NC}"
sleep 1
reboot
;;
"Exit")
clear
echo -e "${BLUE}Thank You Handsome!${NC}"
exit 0
;;
esac
read -n 1 -s -r -p "Press any key to continue..."; echo
done