-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·440 lines (387 loc) · 13.9 KB
/
install.sh
File metadata and controls
executable file
·440 lines (387 loc) · 13.9 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
#!/usr/bin/env bash
# Archer Compatibility Suite v2.0
# Comprehensive Acer laptop compatibility suite for Arch Linux
# Supports: Nitro, Predator, Helios, Triton, Swift, Aspire, and more
set -euo pipefail
# --- Resolve script directory ---
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# --- Source libraries ---
source "$SCRIPT_DIR/lib/utils.sh"
source "$SCRIPT_DIR/lib/detect.sh"
source "$SCRIPT_DIR/lib/manifest.sh"
# --- Module registry ---
MODULE_IDS=("driver" "battery" "gpu" "touchpad" "audio" "wifi" "power" "thermal" "gui" "gamemode" "audio-enhance" "camera-enhance" "firmware")
MODULE_LABELS=(
"Linuwu-Sense Kernel Driver"
"Battery Charge Limit (80%)"
"GPU Switching (EnvyControl)"
"Touchpad Fix (I2C HID)"
"Audio Fix (SOF/ALSA)"
"WiFi/Bluetooth Troubleshooting"
"Power Management (TLP)"
"Kernel Thermal Profiles"
"Archer GUI (Control Panel)"
"Game Mode Support"
"Audio Enhancement (Noise Suppression)"
"Camera Enhancement (Virtual Camera)"
"Firmware Update Advisor"
)
MODULE_SELECTED=()
INSTALLED_FILES=""
INSTALLED_DKMS=""
INSTALLED_PACKAGES=""
# --- CLI argument parsing ---
SELECT_ALL_RECOMMENDED=0
EXPLICIT_MODULES=""
SHOW_HELP=0
SHOW_VERSION=0
VERIFY_ONLY=0
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--all) SELECT_ALL_RECOMMENDED=1 ;;
--modules) EXPLICIT_MODULES="$2"; shift ;;
--no-confirm) NO_CONFIRM=1 ;;
--dry-run) DRY_RUN=1 ;;
--verbose) VERBOSE=1 ;;
--log) LOG_FILE="$2"; shift ;;
--verify) VERIFY_ONLY=1 ;;
--help|-h) SHOW_HELP=1 ;;
--version|-v) SHOW_VERSION=1 ;;
*) error "Unknown option: $1. Use --help for usage." ;;
esac
shift
done
}
show_help() {
echo "Archer Compatibility Suite v${INSTALLER_VERSION}"
echo ""
echo "Usage: ./install.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --all Install all recommended modules (non-interactive)"
echo " --modules LIST Comma-separated list of modules to install"
echo " --verify Check status of previously installed modules"
echo " --no-confirm Skip all confirmation prompts"
echo " --dry-run Show what would be done without making changes"
echo " --verbose Enable debug output for troubleshooting"
echo " --log FILE Write all output to FILE (in addition to console)"
echo " --help, -h Show this help message"
echo " --version, -v Show version"
echo ""
echo "Available modules:"
echo " driver Linuwu-Sense kernel driver for fan/RGB hardware access (DKMS)"
echo " battery Limits battery charging to 80% via acer-wmi-battery"
echo " gpu EnvyControl for NVIDIA Optimus hybrid graphics switching"
echo " touchpad Fix I2C HID touchpad detection (module reload, kernel params)"
echo " audio SOF firmware, ALSA configuration, and audio codec fixes"
echo " wifi Diagnose and fix WiFi/Bluetooth issues for various chipsets"
echo " power TLP power management with Acer-optimized configuration"
echo " thermal Native kernel thermal profiles via acer_wmi (kernel 6.8+)"
echo " gui GTK4/Adwaita control panel and hardware daemon"
echo " gamemode Linux Game Mode with performance governor switching"
echo " audio-enhance Noise suppression via PipeWire/rnnoise"
echo " camera-enhance Virtual camera with background blur (v4l2loopback)"
echo " firmware Firmware update advisor via fwupd"
echo ""
echo "Interactive mode (default): Detects hardware and presents a menu."
}
# --- Menu display and interaction ---
display_menu() {
echo ""
echo -e "${_BOLD}=== Archer Compatibility Suite v${INSTALLER_VERSION} ===${_RESET}"
echo ""
print_hw_summary
echo ""
echo -e "${_BOLD}Select modules to install:${_RESET}"
for i in "${!MODULE_IDS[@]}"; do
local id="${MODULE_IDS[$i]}"
local label="${MODULE_LABELS[$i]}"
local num=$((i + 1))
local marker=" "
local tag=""
# Determine tag
if is_in_list "$id" "${RECOMMENDED_MODULES[*]}"; then
tag="${_GREEN}[RECOMMENDED]${_RESET}"
elif is_in_list "$id" "${OPTIONAL_MODULES[*]}"; then
tag="[OPTIONAL]"
fi
# Check conflicts
if [[ "$id" = "thermal" ]] && [[ "${MODULE_SELECTED[0]}" -eq 1 ]]; then
tag="${_RED}[CONFLICTS WITH #1]${_RESET}"
fi
if [[ "$id" = "driver" ]] && [[ "${MODULE_SELECTED[7]}" -eq 1 ]]; then
tag="${_RED}[CONFLICTS WITH #8]${_RESET}"
fi
# GUI dependency hint
if [[ "$id" = "gui" ]] && [[ "${MODULE_SELECTED[0]}" -eq 0 ]]; then
tag="${tag} ${_YELLOW}(needs #1 Linuwu-Sense)${_RESET}"
fi
# Selection marker
if [[ "${MODULE_SELECTED[$i]}" -eq 1 ]]; then
marker="${_GREEN}*${_RESET}"
fi
printf " [%b] %d. %-40s %b\n" "$marker" "$num" "$label" "$tag"
done
echo ""
echo "Toggle: Enter number (1-${#MODULE_IDS[@]}) | a=all recommended | n=none | c=confirm"
}
is_in_list() {
local item="$1"
local list="$2"
[[ " $list " == *" $item "* ]]
}
init_selections() {
MODULE_SELECTED=()
for i in "${!MODULE_IDS[@]}"; do
local id="${MODULE_IDS[$i]}"
if is_in_list "$id" "${RECOMMENDED_MODULES[*]}"; then
MODULE_SELECTED+=(1)
else
MODULE_SELECTED+=(0)
fi
done
}
check_conflicts() {
# driver (#0) and thermal (#7) conflict
if [[ "${MODULE_SELECTED[0]}" -eq 1 ]] && [[ "${MODULE_SELECTED[7]}" -eq 1 ]]; then
warn "Linuwu-Sense driver and Kernel Thermal Profiles both selected."
warn "These conflict: Linuwu-Sense blacklists acer_wmi, which thermal profiles require."
warn "Please deselect one of them."
return 1
fi
return 0
}
run_menu() {
while true; do
display_menu
read -rp "> " choice
case "$choice" in
[1-9]|[1-9][0-9])
if [[ "$choice" -le "${#MODULE_IDS[@]}" ]] 2>/dev/null; then
local idx=$((choice - 1))
if [[ "${MODULE_SELECTED[$idx]}" -eq 1 ]]; then
MODULE_SELECTED[idx]=0
else
MODULE_SELECTED[idx]=1
fi
else
warn "Invalid number. Enter 1-${#MODULE_IDS[@]}, a, n, or c."
fi
;;
a|A)
init_selections
;;
n|N)
for i in "${!MODULE_SELECTED[@]}"; do
MODULE_SELECTED[i]=0
done
;;
c|C)
if check_conflicts; then
break
fi
;;
*)
warn "Invalid input. Enter 1-${#MODULE_IDS[@]}, a, n, or c."
;;
esac
done
}
# --- Module execution ---
install_shared_deps() {
log "Installing shared system dependencies..."
debug "Kernel headers package: $KERNEL_HEADERS"
# Verify the kernel headers package exists in repos before attempting install
if ! pacman -Si "$KERNEL_HEADERS" &>/dev/null && ! pacman -Qi "$KERNEL_HEADERS" &>/dev/null; then
warn "Kernel headers package '$KERNEL_HEADERS' not found in repos or installed."
warn "DKMS modules may fail to build. Check: pacman -Ss headers"
fi
local deps=(base-devel dkms git curl "$KERNEL_HEADERS" python-pip)
# Clang-built kernels require clang/llvm toolchain for DKMS module compilation
if [[ "$IS_CLANG_KERNEL" -eq 1 ]]; then
log "Clang-built kernel detected — including LLVM toolchain for DKMS builds."
deps+=(clang llvm)
fi
run_sudo pacman -Syu --needed --noconfirm "${deps[@]}"
}
run_selected_modules() {
local selected_names=()
for i in "${!MODULE_IDS[@]}"; do
if [[ "${MODULE_SELECTED[$i]}" -eq 1 ]]; then
local id="${MODULE_IDS[$i]}"
local label="${MODULE_LABELS[$i]}"
selected_names+=("$id")
# GUI dependency warning
if [[ "$id" = "gui" ]]; then
if ! is_in_list "driver" "${selected_names[*]}" && \
! dkms status 2>/dev/null | grep -q "linuwu-sense"; then
warn "Linuwu-Sense driver not installed. The daemon will have limited functionality."
warn "Consider installing the 'driver' module for full hardware control."
fi
fi
section "Installing: $label"
source "$SCRIPT_DIR/modules/${id}.sh"
if ! module_install; then
warn "Module $id failed to install. Continuing..."
continue
fi
fi
done
# Write manifest
local modules_joined="${selected_names[*]}"
write_manifest "$modules_joined" "$INSTALLED_FILES" "$INSTALLED_DKMS" "$INSTALLED_PACKAGES"
}
verify_modules() {
section "Verification"
local total=0
local passed=0
for i in "${!MODULE_IDS[@]}"; do
if [[ "${MODULE_SELECTED[$i]}" -eq 1 ]]; then
local id="${MODULE_IDS[$i]}"
local label="${MODULE_LABELS[$i]}"
total=$((total + 1))
# Re-source to restore this module's function definitions (each module
# overrides the same names: module_verify, module_install, etc.)
source "$SCRIPT_DIR/modules/${id}.sh"
if module_verify; then
success "$label"
passed=$((passed + 1))
else
warn "$label (check warnings above)"
fi
fi
done
echo ""
log "Verification: $passed/$total modules passed"
}
# --- Main entry point ---
main() {
parse_args "$@"
if [[ "$SHOW_VERSION" -eq 1 ]]; then
echo "Archer Compatibility Suite v${INSTALLER_VERSION}"
exit 0
fi
if [[ "$SHOW_HELP" -eq 1 ]]; then
show_help
exit 0
fi
# Standalone verify mode: check installed modules from manifest
if [[ "$VERIFY_ONLY" -eq 1 ]]; then
if ! has_manifest; then
error "No install manifest found. Nothing to verify."
fi
section "Verifying Installed Modules"
local mods
mods=$(read_manifest_modules)
local total=0
local passed=0
for id in $mods; do
local mod_file="$SCRIPT_DIR/modules/${id}.sh"
if [[ -f "$mod_file" ]]; then
total=$((total + 1))
source "$mod_file"
if module_verify; then
success "$MODULE_NAME"
passed=$((passed + 1))
else
warn "$MODULE_NAME (check warnings above)"
fi
else
warn "Module file not found: $mod_file"
fi
done
echo ""
log "Verification: $passed/$total modules passed"
exit 0
fi
if [[ "$DRY_RUN" -eq 1 ]]; then
log "DRY RUN mode enabled. No changes will be made."
fi
# Run hardware detection
log "Detecting hardware..."
detect_all
build_recommendations
# Vendor check
if [[ "$ACER_SYS_VENDOR" != *"Acer"* ]] && [[ "$ACER_PRODUCT_NAME" == "Unknown" ]]; then
warn "This does not appear to be an Acer system."
warn "Some modules may not function correctly."
fi
# Distro check
if [[ "$DISTRO_FAMILY" != "arch" ]]; then
warn "This installer is designed for Arch-based distributions."
warn "Detected: ${DISTRO_NAME:-Unknown} (family: $DISTRO_FAMILY)"
confirm "Continue anyway?" || exit 0
fi
# Initialize selections
init_selections
# Handle non-interactive modes
if [[ -n "$EXPLICIT_MODULES" ]]; then
# Reset all, then select explicit modules
for i in "${!MODULE_SELECTED[@]}"; do
MODULE_SELECTED[i]=0
done
IFS=',' read -ra explicit_list <<< "$EXPLICIT_MODULES"
for mod in "${explicit_list[@]}"; do
local found=0
for i in "${!MODULE_IDS[@]}"; do
if [[ "${MODULE_IDS[$i]}" = "$mod" ]]; then
MODULE_SELECTED[i]=1
found=1
fi
done
if [[ "$found" -eq 0 ]]; then
warn "Unknown module: '$mod' (available: ${MODULE_IDS[*]})"
fi
done
if ! check_conflicts; then
error "Module conflict detected. Aborting."
fi
elif [[ "$SELECT_ALL_RECOMMENDED" -eq 1 ]]; then
# Already initialized with recommendations
:
else
# Interactive menu
run_menu
fi
# Count selected modules
local count=0
for sel in "${MODULE_SELECTED[@]}"; do
count=$((count + sel))
done
if [[ "$count" -eq 0 ]]; then
log "No modules selected. Nothing to install."
exit 0
fi
# Display selected modules
section "Installation Plan"
for i in "${!MODULE_IDS[@]}"; do
if [[ "${MODULE_SELECTED[$i]}" -eq 1 ]]; then
echo " - ${MODULE_LABELS[$i]}"
fi
done
echo ""
if [[ "$NO_CONFIRM" -eq 0 ]] && [[ "$SELECT_ALL_RECOMMENDED" -eq 0 ]] && [[ -z "$EXPLICIT_MODULES" ]]; then
confirm "Proceed with installation?" || exit 0
fi
# Install shared dependencies
install_shared_deps
# Run selected modules
run_selected_modules
# Verify
verify_modules
# Final summary
section "Installation Complete"
success "All selected modules have been installed."
if [[ "$REBOOT_REQUIRED" -eq 1 ]]; then
echo ""
warn "A reboot is required for some changes to take effect."
fi
echo ""
log "Manifest saved to: $MANIFEST_FILE"
log "To uninstall, run: ./uninstall.sh"
}
# Only run main when executed directly (not when sourced for testing)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi