chore(install): add --yes flag, use subshell, clean up git output

- Add -y/--yes flag to skip interactive prompts
- Replace cd/cd- with subshell in app-capture build
- Replace fragile grep -v pipe with stderr redirect for git output
- Total steps still matches progress calls
This commit is contained in:
sankalp committed 2026-07-12 19:28:55 +05:45
1 parent ae90b85f75
commit d0e1f7090a
1 file changed
+27 -14
+27 -14
View File
@@ -17,6 +17,13 @@ set -e
set -u set -u
set -o pipefail set -o pipefail
AUTO_YES=false
for arg in "$@"; do
case "$arg" in
-y|--yes) AUTO_YES=true ;;
esac
done
REPO_URL="https://github.com/S4NKALP/Modus.git" REPO_URL="https://github.com/S4NKALP/Modus.git"
INSTALL_DIR="$HOME/.config/Modus" INSTALL_DIR="$HOME/.config/Modus"
@@ -196,7 +203,11 @@ progress "Package information"
info "Total packages to install: ${BOLD}${#PACKAGES[@]}${RESET}" info "Total packages to install: ${BOLD}${#PACKAGES[@]}${RESET}"
echo "" echo ""
read -rp " ${YELLOW}${INFO}${RESET} View full package list? (y/N): " view_packages if [ "$AUTO_YES" = false ]; then
read -rp " ${YELLOW}${INFO}${RESET} View full package list? (y/N): " view_packages
else
view_packages="n"
fi
if [[ "$view_packages" =~ ^[Yy]$ ]]; then if [[ "$view_packages" =~ ^[Yy]$ ]]; then
echo "" echo ""
printf " ${DIM}• %s${RESET}\n" "${PACKAGES[@]}" printf " ${DIM}• %s${RESET}\n" "${PACKAGES[@]}"
@@ -204,7 +215,11 @@ if [[ "$view_packages" =~ ^[Yy]$ ]]; then
fi fi
# Confirmation # Confirmation
read -rp " ${BOLD}Proceed with installation? (y/N):${RESET} " confirm if [ "$AUTO_YES" = false ]; then
read -rp " ${BOLD}Proceed with installation? (y/N):${RESET} " confirm
else
confirm="y"
fi
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
warn "Installation cancelled by user" warn "Installation cancelled by user"
exit 0 exit 0
@@ -223,7 +238,7 @@ else
step "Installing yay-bin..." step "Installing yay-bin..."
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
( (
git clone --quiet --depth=1 https://aur.archlinux.org/yay-bin.git "$tmpdir/yay-bin" 2>&1 | grep -v "Cloning into" || true git clone --quiet --depth=1 https://aur.archlinux.org/yay-bin.git "$tmpdir/yay-bin" 2>/dev/null || true
cd "$tmpdir/yay-bin" cd "$tmpdir/yay-bin"
makepkg -si --noconfirm >/dev/null 2>&1 makepkg -si --noconfirm >/dev/null 2>&1
) & ) &
@@ -242,11 +257,11 @@ progress "Setting up Modus repository"
if [ -d "$INSTALL_DIR" ]; then if [ -d "$INSTALL_DIR" ]; then
step "Updating existing repository..." step "Updating existing repository..."
git -C "$INSTALL_DIR" pull --quiet 2>&1 | grep -v "Already up to date" || true git -C "$INSTALL_DIR" pull --quiet 2>/dev/null || true
success "Repository updated" success "Repository updated"
else else
step "Cloning repository..." step "Cloning repository..."
git clone --quiet "$REPO_URL" "$INSTALL_DIR" 2>&1 | grep -v "Cloning into" || true git clone --quiet "$REPO_URL" "$INSTALL_DIR" 2>/dev/null || true
success "Repository cloned" success "Repository cloned"
fi fi
info "Location: ${INSTALL_DIR}" info "Location: ${INSTALL_DIR}"
@@ -315,17 +330,15 @@ progress "Building App Capture module"
step "Compiling libappcapture.so..." step "Compiling libappcapture.so..."
if [ -d "$INSTALL_DIR/src/window/switcher/app-capture" ]; then if [ -d "$INSTALL_DIR/src/window/switcher/app-capture" ]; then
cd "$INSTALL_DIR/src/window/switcher/app-capture" if (
if meson setup builddir --wipe >/dev/null 2>&1 || meson setup builddir >/dev/null 2>&1; then cd "$INSTALL_DIR/src/window/switcher/app-capture"
if meson compile -C builddir >/dev/null 2>&1; then meson setup builddir --wipe >/dev/null 2>&1 || meson setup builddir >/dev/null 2>&1
success "libappcapture.so built successfully" meson compile -C builddir >/dev/null 2>&1
else ); then
warn "Failed to compile App Capture module" success "libappcapture.so built successfully"
fi
else else
warn "Failed to setup App Capture builddir" warn "Failed to compile App Capture module"
fi fi
cd - >/dev/null
else else
warn "App Capture module directory not found" warn "App Capture module directory not found"
fi fi