Files
starburst/v2/arch-minimal.sh
2025-12-11 10:57:35 +01:00

155 lines
5.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
##########################
# Color helpers (printf-safe, no tput)
##########################
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
CYAN="\033[0;36m"
GRAY="\033[0;37m"
BOLD="\033[1m"
RESET="\033[0m"
# Disable colors if output is not a terminal
if [ ! -t 1 ]; then
RED="" GREEN="" YELLOW="" CYAN="" GRAY="" BOLD="" RESET=""
fi
say_red() { printf "\n"; printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
say_green() { printf "\n"; printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
say_yellow() { printf "\n"; printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
say_cyan() { printf "\n"; printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
say_gray() { printf "\n"; printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
say_bold() { printf "\n"; printf "%b%s%b\n" "$BOLD" "$*" "$RESET"; }
##########################
# Use exported variables from main detection script
##########################
OS="${DETECTED_OS:-arch}"
DDE="${DETECTED_DE}"
DE="${SELECTED_DE:-none}"
TWM="${SELECTED_TWM:-none}"
INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
##########################
# Helper functions
##########################
install_packages() { sudo pacman -Sy; sudo pacman -S --noconfirm --needed "$@"; }
is_package_installed() { pacman -Qi "$@" &>/dev/null; }
remove_packages() {
local packages_to_remove=()
# 1. Identify which packages are actually installed
for pkg in "$@"; do
if is_package_installed "$pkg"; then
packages_to_remove+=("$pkg")
else
say_gray "Package '$pkg' not found. Skipping removal."
fi
done
# 2. Only run pacman if there are packages to remove
if [ ${#packages_to_remove[@]} -gt 0 ]; then
say_cyan "Removing packages: ${packages_to_remove[*]}"
sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true
else
say_gray "No packages to remove from the list."
fi
}
say_yellow "Starting minimal setup..."
# Create user directories
mkdir -p "$HOME"/{.bin,.fonts,.icons,.themes,DATA} "$HOME/.local/share/"{icons,themes,applications} "$HOME/.config/"{autostart,gtk-{3.0,4.0},variety,fish,neofetch}
# Removing unwanted drivers
say_yellow "GET RID OF BROADCOM AND REALTEK DRIVERS"
remove_packages broadcom-wl-dkms r8168-dkms rtl8821cu-morrownr-dkms-git
# Removing unwanted kernels
say_yellow "KEEP LINUX KERNEL GET RID OF THE OTHER KERNELS"
# Ensure at least one kernel remains
if pacman -Qi linux &> /dev/null && pacman -Qi linux-headers &> /dev/null; then
# Define all the kernels and their headers you want to remove
KERNELS_TO_REMOVE=(
linux-lts-headers linux-lts
linux-zen-headers linux-zen
linux-hardened-headers linux-hardened
linux-rt-headers linux-rt
linux-rt-lts-headers linux-rt-lts
linux-cachyos-headers linux-cachyos
linux-xanmod-headers linux-xanmod
)
remove_package() {
local package=$1
# Check if the package is installed
if pacman -Q $package &> /dev/null; then
say_yellow "$package is installed. Removing..."
sudo pacman -Rns --noconfirm $package
else
say_yellow "$package is not installed."
fi
}
# Loop over the array and remove each kernel package
for kernel in "${KERNELS_TO_REMOVE[@]}"; do
remove_package "$kernel"
done
else
echo "Cannot proceed: At least one kernel must remain installed."
fi
# Removing unwanted video drivers
remove_packages xf86-video-amdgpu xf86-video-ati xf86-video-fbdev xf86-video-nouveau xf86-video-openchrome xf86-video-vesa
# Install essential tools
install_packages wget curl nano fastfetch lolcat bash-completion starship alacritty hwinfo lshw man-db tree xdg-user-dirs rsync time bat unzip chromium
# Optionally handle fonts
FONT_DIR="$HOME/.local/share/fonts"
FONT_NAME="RobotoMonoNerdFont" # Changed name to reflect the installed files
FONT_ZIP="/tmp/RobotoMono.zip" # Use original ZIP name for download
DOWNLOAD_NAME="RobotoMono"
if ! compgen -G "$FONT_DIR/${FONT_NAME}*.ttf" > /dev/null; then
say_yellow "Installing ${DOWNLOAD_NAME} Nerd Font..."
mkdir -p "$FONT_DIR"
curl -L "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/${DOWNLOAD_NAME}.zip" -o "$FONT_ZIP"
unzip -oq "$FONT_ZIP" -d "$FONT_DIR"
fc-cache -fv
rm "$FONT_ZIP"
say_green "${DOWNLOAD_NAME} installed."
else
say_yellow "${DOWNLOAD_NAME} Nerd Font is already installed in $FONT_DIR. Skipping installation."
fi
# allow Chromium login with Google Account
# Define the configuration file path
CONF="$HOME/.config/chromium-flags.conf"
# Check if the file exists, or create it if it doesn't
if [[ ! -f "$CONF" ]]; then
# Create the file if it doesn't exist
touch "$CONF"
echo "Created new Chromium flags file: $CONF"
fi
# Add the OAuth 2.0 Client ID if it's not already there
# -q: quiet, -x: match whole line, -F: literal string match
grep -qxF -- "--oauth2-client-id=77185425430.apps.googleusercontent.com" "$CONF" || \
echo "--oauth2-client-id=77185425430.apps.googleusercontent.com" >>"$CONF"
# Add the OAuth 2.0 Client Secret if it's not already there
grep -qxF -- "--oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT" "$CONF" || \
echo "--oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT" >>"$CONF"
say_green "Chromium flags for Google Account login have been configured."
# Enable basic services
#sudo systemctl enable chronyd.service
sudo systemctl enable fstrim.timer
# End of script
say_green "Minimal setup completed."