Merge branch 'feat/lib-modules'

This commit is contained in:
2026-10-27 10:27:05 +01:00
11 changed files with 782 additions and 64 deletions
Regular → Executable
+90 -63
View File
@@ -1,30 +1,10 @@
#!/bin/bash
#
# setup.sh — unified Fedora configuration
# Target: bare/minimal Fedora 44 and newer
#
set -uo pipefail
#------------------------------------------
# Argument parsing (must come before anything reads DEBUG_MODE)
#------------------------------------------
DEBUG_MODE=false
for arg in "$@"; do
case "$arg" in
-d|--debug) DEBUG_MODE=true ;;
-h|--help)
cat <<'EOF'
Usage: ./setup.sh [-d|--debug]
-d, --debug Pause after each section instead of aborting on error
-h, --help Show this help
EOF
exit 0
;;
*) echo "Unknown argument: $arg (try --help)" >&2; exit 2 ;;
esac
done
export DEBUG_MODE
# Abort on error unless we are walking through it step by step
if [[ "$DEBUG_MODE" == "true" ]]; then
set +e
else
set -e
fi
#------------------------------------------
# Color helpers (printf-safe, no tput)
#------------------------------------------
@@ -37,19 +17,22 @@ BLUE='\033[0;34m'
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='' PURPLE='' BLUE='' GRAY='' BOLD='' RESET=''
fi
color_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
color_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
color_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
color_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
color_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
#------------------------------------------
# Helper functions
# Defaults + argument parsing
# DEBUG_MODE must be initialised before anything reads it under set -u.
#------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pause_if_debug() {
if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
echo
@@ -63,8 +46,10 @@ pause_if_debug() {
echo
fi
}
install_packages() { sudo dnf install -y "$@"; }
is_package_installed() { rpm -q "$@" &>/dev/null; }
remove_packages() {
local packages_to_remove=()
for pkg in "$@"; do
@@ -72,44 +57,54 @@ remove_packages() {
packages_to_remove+=("$pkg")
fi
done
if [ ${#packages_to_remove[@]} -gt 0 ]; then
color_cyan "Removing packages: ${packages_to_remove[*]}"
sudo dnf remove -y "${packages_to_remove[@]}"
fi
}
#------------------------------------------
# 0 STARTING the script
# Preconditions
#------------------------------------------
#------------------------------------------
# Script Version 1.1
# Script Version 1.0
#------------------------------------------
# Wipe the terminal history view cleanly. Guarded: without TERM (cron, piped
# installs, ssh without a tty) `clear` fails and would abort the whole run.
clear 2>/dev/null || true
clear # Wipe the terminal history view cleanly for the main menu execution
if [[ "$DEBUG_MODE" == "true" ]]; then
color_red "!!! DEBUG MODE ENABLED !!!"
color_red "The script will pause after each major section."
echo
fi
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Script version 1.1"
color_yellow "Script version 1.0"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------
# OS Detection
# OS gate — Fedora only, 44+
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Start OS Detection"
color_yellow "----------------------------------------------------------------"
echo
source /etc/os-release
OS_ID="${ID:-unknown}"; OS_ID="${OS_ID,,}"
OS_LIKE="${ID_LIKE:-}"; OS_LIKE="${OS_LIKE,,}"
OS_ID="${ID,,}"
OS_LIKE="${ID_LIKE:-}"
OS_LIKE="${OS_LIKE,,}"
OS_VERSION="${VERSION_ID:-unknown}"
OS_PRETTY="${PRETTY_NAME:-unknown}"
OS_PRETTY="$PRETTY_NAME"
OS=""
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
case "$OS_ID" in
fedora) OS="fedora" ;;
*)
@@ -118,6 +113,7 @@ case "$OS_ID" in
fi
;;
esac
if [[ -n "$OS" ]]; then
color_cyan "----------------------------------------------------------------"
color_cyan "Detected OS: $OS_PRETTY"
@@ -130,72 +126,79 @@ else
color_red "----------------------------------------------------------------"
exit 1
fi
# Minimum supported release: this repo targets Fedora 44 and newer.
FEDORA_REL=$(rpm -E %fedora)
if [[ "$FEDORA_REL" =~ ^[0-9]+$ ]] && (( FEDORA_REL < 44 )); then
color_red "$OS_PRETTY reports release $FEDORA_REL, but this setup targets Fedora 44+."
color_red "Refusing to continue. Re-run on F44 or newer."
exit 1
fi
pause_if_debug
#------------------------------------------
# 1 Basic Settings
# 1 Base settings
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "1 Basic Settings"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------
# 1.1 Ensure base is ready for installation
#------------------------------------------
if ! command -v curl >/dev/null 2>&1; then
color_yellow "curl is not installed. Installing..."
info "curl missing. Installing..."
install_packages curl
fi
# config-manager lives in dnf5-plugins; make sure it is present before using it
if ! dnf config-manager --help >/dev/null 2>&1; then
color_yellow "dnf config-manager missing. Installing dnf5-plugins..."
install_packages dnf5-plugins
fi
pause_if_debug
#------------------------------------------
# 1.2 Update and Enable Repos + Flatpak
#------------------------------------------
color_cyan "Optimizing DNF for speed..."
# 1. Increase parallel downloads (allows downloading multiple packages at once)
# 2. Set dnf to set YES as default instead of NO
sudo dnf config-manager setopt max_parallel_downloads=20
sudo dnf config-manager setopt defaultyes=True
color_green "DNF optimized. Refreshing metadata..."
sudo dnf makecache --refresh
color_cyan "Enabling RPM Fusion repositories for Fedora $(rpm -E %fedora)..."
# Define the version variable for readability
FEDORA_VER=$(rpm -E %fedora)
color_cyan "Enabling RPM Fusion repositories for Fedora ${FEDORA_VER}..."
color_yellow "Checking for updates and sources..."
sudo dnf check-update || true
# Check if flatpak is installed, if not, install it
if ! command -v flatpak &> /dev/null; then
color_yellow "Flatpak not found. Installing..."
sudo dnf install -y flatpak
fi
color_cyan "Enabling Flathub..."
# Using --if-not-exists is good practice to prevent errors on re-runs
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_VER}.noarch.rpm" \
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_VER}.noarch.rpm"
color_cyan "Enabling Flathub (system-wide)..."
# --if-not-exists keeps this idempotent on re-runs
sudo flatpak remote-add --if-not-exists --system flathub https://dl.flathub.org/repo/flathub.flatpakrepo
color_cyan "Enabling full Flathub support..."
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# Update the system
color_gray "Updating the system"
echo
echohttps://git.ku-it.org/terrabeam/starburst.git
sudo dnf update -y
pause_if_debug
#------------------------------------------
# 2 Tiling Window Manager Selection
# Tiling Window Manager Selection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "2 Tiling WM Selection"
color_yellow "Tiling WM Selection"
color_yellow "----------------------------------------------------------------"
echo
while true; do
echo
color_gray "Select a tiling window manager:"
@@ -208,6 +211,7 @@ while true; do
if ! read -t 15 -rp "Enter choice [1/2/3/4/x] (default: x): " choice; then
choice="x"
fi
case "${choice,,}" in
1) TWM="chadwm"; break ;;
2) TWM="hyprland"; break ;;
@@ -217,23 +221,43 @@ while true; do
*) echo "Invalid option. Please enter 1, 2, 3, 4 or x." ;;
esac
done
echo
color_cyan "----------------------------------------------------------------"
color_cyan "Selected Tiling WM: $TWM"
color_cyan "----------------------------------------------------------------"
export TWM
pause_if_debug
#------------------------------------------
# 3 Tiling Window Manager installation
# 5. Tiling Window Manager installation
#------------------------------------------
if [[ -z "$TWM" ]]; then
step "4 Tiling window manager"
rule
printf "\n"
echo " 1) Niri (Wayland, scrollable)"
echo " 2) Hyprland (Wayland, dynamic)"
echo " 3) MangoWC (Wayland, dwl-based, Terra repo)"
echo " 4) chadwm (X11, dwm fork, built from source)"
echo " 5) None"
printf "\n"
choice=$(ask_choice "Select tiling window manager [1/2/3/4/5]" "1" 1 2 3 4 5)
case "$choice" in
1) TWM="niri" ;;
2) TWM="hyprland" ;;
3) TWM="mango" ;;
4) TWM="chadwm" ;;
5) TWM="none" ;;
esac
fi
case "$TWM" in
chadwm|hyprland|mango|niri)
color_yellow "Installing $TWM"
SCRIPT_NAME="$SCRIPT_DIR/${TWM}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan "Running $SCRIPT_NAME"
# Run in a subshell: a module's set -e / exit cannot leak into this script
( source "$SCRIPT_NAME" )
source "$SCRIPT_NAME"
else
color_red "Error: $SCRIPT_NAME not found!"
exit 1
@@ -243,11 +267,14 @@ case "$TWM" in
color_gray "No tiling window manager selected, skipping TWM installation."
;;
esac
pause_if_debug
echo
color_yellow "----------------------------------------------------------------"
color_yellow "End Detection"
color_yellow "----------------------------------------------------------------"
color_green "Fedora setup complete."
color_red "The installation has finished. A reboot is recommended."
# Reboots are dangerous to automate; we use a shorter timeout and default to No
@@ -265,4 +292,4 @@ if read -t 10 -rp "Reboot now? [y/N]: " reboot_choice; then
else
color_yellow "No input detected. Skipping reboot for safety."
exit 0
fi
fi