Restructure for bare Fedora: lib/ + modules/, DE selection restored

Splits setup.sh into lib/common.sh, lib/session.sh and seven modules
(3 DE, 4 TWM). Targets a bare Fedora 44+ install.

Fixes carried over from the first build:
- DEBUG_MODE was unbound under set -u, aborting the script at the version banner
- mangled 'echohttps://...' line left over from the starburst split
- set -e was missing entirely; --debug flag parsing restored
- unguarded 'clear' aborted the run without TERM
- $PRETTY_NAME unguarded under set -u
- modules were sourced, leaking shell options into the parent
- Flathub added twice (system-wide + per-user)
- no dnf5-plugins check before using 'dnf config-manager'
- no Fedora release gate
- /usr/share/xsessions assumed to exist when writing session entries
This commit is contained in:
Pathfinder
2026-10-27 10:15:04 +01:00
parent 4f59afbac1
commit 234bf8214e
11 changed files with 973 additions and 220 deletions
+133 -1
View File
@@ -1,3 +1,135 @@
# Fedora Unified Config # Fedora Unified Config
The goal for this repo is to create a unified configuration for Fedora 44 and newer. Unified configuration for **bare/minimal Fedora 44 and newer**. Pick a desktop
environment and optionally a tiling window manager; the script wires up repos,
packages, the greeter and the session entry.
This repo is the Fedora-only successor to `starburst`. Everything multi-distro
(Arch, Debian, Ubuntu branches, OS guessing, per-distro package helpers) is gone
on purpose.
## Usage
```bash
git clone https://git.ku-it.org/yuri/fedora.git
cd fedora
./setup.sh # interactive: choose DE, then TWM
./setup.sh --debug # same, but pause after each section
```
Non-interactive:
```bash
./setup.sh --yes --de=none --twm=niri
./setup.sh --yes --de=gnome --twm=none
```
Run as your **normal user**, not root. `sudo` is used where needed.
## Layout
```
setup.sh entrypoint: args, preconditions, base setup, menus, dispatch
lib/common.sh colours, logging, dnf helpers, rpmfusion/terra, nerd fonts
lib/session.sh display-manager detection/switching, session entries
modules/de/{gnome,plasma,xfce}.sh
modules/twm/{niri,hyprland,mango,chadwm}.sh
```
Modules are **separate processes**, not sourced into `setup.sh`. That means a
module's own `set -e` cannot leak into the caller, and every module can be run
on its own for testing:
```bash
DE=none TWM=niri DEBUG_MODE=false bash modules/twm/niri.sh
```
Each module pulls in `lib/` by relative path, so it works both ways.
## Selection matrix
| DE | TWM | Result |
|---|---|---|
| any | any | DE provides the session; TWM is added alongside it |
| `none` | any | TWM-only machine, SDDM installed as the greeter |
| any | `none` | plain desktop, no tiling WM |
| `none` | `none` | **refused** — that is not a graphical system |
### Desktop environments
| DE | dnf group (tried in order) | native greeter |
|---|---|---|
| `gnome` | `gnome-desktop`, `gnome-desktop-environment`, `workstation-product-environment` | gdm |
| `plasma` | `kde-desktop`, `kde-desktop-environment` | sddm |
| `xfce` | `xfce-desktop`, `xfce-desktop-environment` | lightdm |
### Tiling window managers
| TWM | Source | Session type | Notes |
|---|---|---|---|
| `niri` | Fedora repos + Terra (for `noctalia`) | Wayland | Ships its own session entry |
| `hyprland` | Fedora repos | Wayland | Ships its own session entry |
| `mango` | **Terra repo only** | Wayland | Session entry written if the package lacks one |
| `chadwm` | **built from source** | **X11** | dwm fork; not packaged anywhere for Fedora |
`chadwm` is the only X11 entry in the menu. The other three are Wayland
compositors — do not expect the same config story from it.
## Display manager policy
* A **DE module** leaves the DE's own greeter alone (GNOME→gdm, Plasma→sddm,
XFCE→lightdm). It never fights a desktop over its own login screen.
* A **TWM module** enforces **SDDM**, because it is the only greeter that lists
Wayland compositors *and* X11 sessions in one menu.
* Either way `graphical.target` becomes the default.
## Design rules
1. **Fail loudly, early.** `set -e` is on unless `--debug`. Unsupported distro,
release below 44, `DE=none` + `TWM=none`, and a missing module all abort with
an explanation instead of half-installing.
2. **Be idempotent.** Re-running must be safe. Repos are checked with `rpm -q`
before being added, the Nerd Font is skipped if already present, and session
entries are not overwritten.
3. **Prefer official repos, then Terra, then a source build.** That order is why
only `mango` and `chadwm` need special handling.
4. **No silent optional failures.** `install_optional` warns and continues for
nice-to-haves; everything load-bearing uses `install_packages` and aborts.
5. **Guard anything environment-dependent.** `clear` needs `|| true` (no `TERM`
under cron/pipes), `os-release` fields are defaulted, and
`/usr/share/xsessions` is created before writing into it.
## Testing
The script was verified on a non-Fedora host with a stateful stub harness
(fake `sudo`/`dnf`/`rpm`/`systemctl`/`git`/`make`/`curl`, a fake `os-release`,
and sandboxed `/usr` + `$HOME`). Covered: every DE×(TWM|none) combination, the
refusal paths, `--help`/bad args, interactive menus, `--debug` abort, and
re-running for idempotency.
`OS_RELEASE_FILE` is overridable purely so the preconditions can be tested:
```bash
OS_RELEASE_FILE=/tmp/fake-os-release ./setup.sh --yes --de=xfce --twm=chadwm
```
## Known limitations
* `noctalia` and `mangowc` come from **Terra**, a third-party repo. The
package layout there is not guaranteed across Fedora releases; `mango` aborts
with build-from-source instructions if the package is missing.
* Package *names* are not verified by installation in this repo's test harness —
only control flow is. First real run on a fresh F44 box is the actual proof.
* `gnome-tweaks`/`gnome-extensions-app`, `wofi`, `waybar`, `hyprlock` and friends
are installed with `install_optional`, so a rename will warn rather than fail.
## Roadmap
- [ ] Profile files (`--profile=laptop`) instead of individual flags
- [ ] Optional dotfiles layer (noctalia/hyprland/niri configs)
- [ ] `--dry-run` that prints the dnf transaction without applying it
- [ ] Pre-flight report: what is already installed, what would change
## License
See `LICENSE`.
+201
View File
@@ -0,0 +1,201 @@
# shellcheck shell=bash
#------------------------------------------
# lib/common.sh — shared helpers
#
# Sourced by setup.sh and by every module. Modules source it directly, so a
# module can be run standalone for testing:
# DE=none TWM=niri bash modules/twm/niri.sh
#------------------------------------------
# Guard against double-sourcing (setup.sh and a module can both pull it in)
if [[ -n "${_SB_COMMON_LOADED:-}" ]]; then
return 0
fi
_SB_COMMON_LOADED=1
#------------------------------------------
# Colors (printf-safe, no tput)
#------------------------------------------
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
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"; }
#------------------------------------------
# Log levels
#------------------------------------------
info() { color_cyan " $*"; }
ok() { color_green " $*"; }
warn() { color_yellow " $*"; }
err() { color_red " $*" >&2; }
step() { printf "\n"; color_yellow "$*"; }
rule() { printf "%s\n" "----------------------------------------------------------------"; }
#------------------------------------------
# Debug pausing
#------------------------------------------
is_debug() { [[ "${DEBUG_MODE:-false}" == "true" ]]; }
pause_if_debug() {
if is_debug; then
printf "\n"
color_yellow "----------------------------------------------------------------"
read -rp "Section complete. Press [Enter] to continue, or [q] to abort: " debug_choice
if [[ "${debug_choice,,}" == "q" ]]; then
color_red "Script aborted by user."
exit 1
fi
color_yellow "----------------------------------------------------------------"
printf "\n"
fi
}
#------------------------------------------
# Package helpers (dnf5)
#------------------------------------------
install_packages() {
# -y : no prompts
# weak deps on : keep default behaviour, stated explicitly so it is greppable
sudo dnf install -y --setopt=install_weak_deps=True "$@"
}
# Same, but a missing/renamed package warns instead of aborting the whole run.
# Use for anything that is a nice-to-have rather than load-bearing.
install_optional() {
sudo dnf install -y --setopt=install_weak_deps=True "$@" \
|| warn "Optional packages not installed: $*"
}
pkg_installed() {
local p
for p in "$@"; do
rpm -q "$p" &>/dev/null || return 1
done
return 0
}
remove_packages() {
local packages_to_remove=()
for pkg in "$@"; do
if pkg_installed "$pkg"; then
packages_to_remove+=("$pkg")
else
color_gray " Package '$pkg' not installed. Skipping removal."
fi
done
if [ ${#packages_to_remove[@]} -gt 0 ]; then
info "Removing packages: ${packages_to_remove[*]}"
sudo dnf remove -y "${packages_to_remove[@]}"
fi
}
# dnf comps group. Fail loudly with the real group list rather than letting
# dnf's generic "no match" scroll past.
install_group() {
local group="$1"
if ! dnf group info "$group" >/dev/null 2>&1; then
err "No such dnf group: @$group"
err "Available groups on this system:"
dnf group list --hidden 2>/dev/null | sed 's/^/ /' >&2 || true
return 1
fi
sudo dnf group install -y "$group"
}
# Try each candidate group/environment in turn; first one that exists wins.
install_group_any() {
local g
for g in "$@"; do
if dnf group info "$g" >/dev/null 2>&1; then
info "Using dnf group: @$g"
sudo dnf group install -y "$g"
return 0
fi
done
err "None of these dnf groups exist: $*"
dnf group list --hidden 2>/dev/null | sed 's/^/ /' >&2 || true
return 1
}
#------------------------------------------
# Third-party repos
#------------------------------------------
add_terra_repo() {
if pkg_installed terra-release; then
ok "Terra repository already installed."
return 0
fi
info "Adding Terra repository (Fyra Labs)..."
# Terra's own instructions use --nogpgcheck for the bootstrap package;
# once terra-release is in place the repo itself is signature-checked.
sudo dnf install -y --nogpgcheck \
--repofrompath 'terra,https://repos.fyralabs.com/terra$releasever' \
terra-release
}
add_rpmfusion_repo() {
local rel
rel=$(rpm -E %fedora)
if pkg_installed rpmfusion-free-release rpmfusion-nonfree-release; then
ok "RPM Fusion already installed."
return 0
fi
info "Enabling RPM Fusion (free + nonfree) for Fedora ${rel}..."
sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${rel}.noarch.rpm" \
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${rel}.noarch.rpm"
}
#------------------------------------------
# Fonts
#------------------------------------------
# Nerd Fonts are not in the Fedora repos, so pull the release zip from GitHub
# into the user's font dir. Idempotent: skipped if the family is already there.
install_nerd_font() {
local family="${1:-JetBrainsMono}"
local dest="${HOME}/.local/share/fonts/NerdFonts-${family}"
local url="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/${family}.zip"
if [[ -d "$dest" ]] && compgen -G "$dest/*.ttf" >/dev/null; then
ok "Nerd Font ${family} already installed."
return 0
fi
info "Installing Nerd Font ${family}..."
local tmp
tmp=$(mktemp -d)
if ! curl -fsSL -o "$tmp/${family}.zip" "$url"; then
warn "Could not download ${family} Nerd Font. Skipping."
rm -rf "$tmp"
return 0
fi
if ! command -v unzip >/dev/null 2>&1; then
install_packages unzip
fi
mkdir -p "$dest"
unzip -qo "$tmp/${family}.zip" -d "$dest"
rm -rf "$tmp"
fc-cache -f "$dest" >/dev/null 2>&1 || true
ok "Nerd Font ${family} installed to $dest"
}
+91
View File
@@ -0,0 +1,91 @@
# shellcheck shell=bash
#------------------------------------------
# lib/session.sh — display manager and graphical session wiring
#
# DM policy:
# * A DE module leaves its native DM alone (GNOME→gdm, Plasma→sddm, XFCE→lightdm).
# * A TWM module enforces SDDM, because SDDM is the only DM that presents both
# Wayland compositors and X11 sessions in one menu. One greeter, no surprises.
#------------------------------------------
if [[ -n "${_SB_SESSION_LOADED:-}" ]]; then
return 0
fi
_SB_SESSION_LOADED=1
# Name of the active display manager ("sddm", "gdm", "lightdm"), or "" if none.
detect_display_manager() {
local link=/etc/systemd/system/display-manager.service
if [[ -L "$link" ]]; then
basename "$(readlink "$link")" | sed 's/\.service$//'
else
echo ""
fi
}
enable_graphical_target() {
sudo systemctl set-default graphical.target
}
# Make $1 the display manager, disabling whatever is active now.
switch_display_manager() {
local target="$1"
local current
current=$(detect_display_manager)
if [[ "$current" == "$target" ]]; then
ok "Display manager already $target."
else
if [[ -n "$current" ]]; then
info "Disabling current display manager: $current"
# disable may fail if the unit vanished; that is not fatal
sudo systemctl disable "$current" 2>/dev/null || true
fi
info "Enabling display manager: $target"
sudo systemctl enable "$target"
fi
enable_graphical_target
}
# Register a Wayland session so the DM can list it.
# $1 = identifier, $2 = display name, $3 = command
write_wayland_session() {
local id="$1" name="$2" exec_cmd="$3"
local file="/usr/share/wayland-sessions/${id}.desktop"
if [[ -f "$file" ]]; then
ok "Wayland session already registered: $id"
return 0
fi
info "Registering Wayland session: $id"
sudo mkdir -p "$(dirname "$file")"
printf '[Desktop Entry]\nName=%s\nComment=%s\nExec=%s\nType=Application\nDesktopNames=%s\n' \
"$name" "$name session" "$exec_cmd" "$id" | sudo tee "$file" >/dev/null
sudo chmod 644 "$file"
}
# Register an X11 session so the DM can list it.
write_x11_session() {
local id="$1" name="$2" exec_cmd="$3"
local file="/usr/share/xsessions/${id}.desktop"
if [[ -f "$file" ]]; then
ok "X11 session already registered: $id"
return 0
fi
info "Registering X11 session: $id"
# A bare Fedora has no X session yet, so the directory may not exist.
sudo mkdir -p "$(dirname "$file")"
printf '[Desktop Entry]\nName=%s\nComment=%s\nExec=%s\nType=Application\n' \
"$name" "$name session" "$exec_cmd" | sudo tee "$file" >/dev/null
sudo chmod 644 "$file"
}
# Common login-time plumbing every Wayland compositor wants on a bare install.
install_session_prereqs() {
install_packages \
xdg-desktop-portal \
polkit \
pipewire \
pipewire-pulseaudio \
wireplumber
}
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Desktop environment: GNOME"
rule
if pkg_installed gnome-shell; then
ok "GNOME already installed."
else
info "Installing the GNOME desktop..."
# Group names have shifted across releases; take whichever exists.
install_group_any gnome-desktop gnome-desktop-environment workstation-product-environment
install_optional gnome-tweaks gnome-extensions-app
fi
# GNOME ships and enables gdm itself. We deliberately leave it alone: a DE module
# never fights the DE over its own greeter. A TWM module switched on top will
# move the system to SDDM instead.
info "Current display manager: $(detect_display_manager)"
ok "GNOME setup complete."
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Desktop environment: KDE Plasma"
rule
if pkg_installed plasma-workspace; then
ok "Plasma already installed."
else
info "Installing the KDE Plasma desktop..."
install_group_any kde-desktop kde-desktop-environment
fi
# Plasma's native greeter is SDDM; make sure it is actually the active one.
install_packages sddm
switch_display_manager sddm
ok "Plasma setup complete."
+50
View File
@@ -0,0 +1,50 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Desktop environment: XFCE"
rule
if pkg_installed xfce4-session; then
ok "XFCE already installed."
else
info "Installing the XFCE desktop..."
install_group_any xfce-desktop xfce-desktop-environment
install_optional "@xfce-extra-plugins"
fi
# XFCE is X11. It needs an X server present even when it is only the session
# provider for chadwm.
install_packages xorg-x11-server-Xorg xorg-x11-xinit
# XFCE's native greeter is lightdm
if ! pkg_installed lightdm; then
install_packages lightdm
fi
switch_display_manager lightdm
install_nerd_font JetBrainsMono
install_packages alacritty dconf
# Point XFCE's terminal preference at alacritty, seeding the config directly so
# it applies on first login rather than needing a session restart.
XFCONF_DIR="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml"
mkdir -p "$XFCONF_DIR"
info "Seeding XFCE session defaults..."
cat > "$XFCONF_DIR/xfce4-session.xml" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-session" version="1.0">
<property name="general" type="empty">
<property name="TerminalEmulator" type="string" value="alacritty"/>
</property>
</channel>
EOF
ok "XFCE setup complete."
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Tiling window manager: chadwm"
rule
# chadwm is an X11 dwm fork and is not packaged for Fedora anywhere. It is
# built from source. Note this is the only non-Wayland option in the menu.
info "Installing chadwm build dependencies..."
install_packages \
gcc make git \
libX11-devel libXft-devel libXinerama-devel imlib2-devel \
dash xsetroot feh picom rofi alacritty \
xorg-x11-server-Xorg xorg-x11-xinit
CHAD_DIR="$HOME/.config/chadwm"
if [[ ! -d "$CHAD_DIR/.git" ]]; then
info "Cloning chadwm into $CHAD_DIR..."
git clone --depth 1 https://github.com/siduck/chadwm "$CHAD_DIR"
else
ok "chadwm source already present at $CHAD_DIR"
fi
if [[ ! -x /usr/local/bin/chadwm ]]; then
info "Building and installing chadwm..."
# make install needs root to write /usr/local/bin
sudo make -C "$CHAD_DIR/chadwm" install
else
ok "chadwm binary already installed."
fi
# Session wrapper: dwm forks do not do autostart themselves, so set up the
# wallpaper/compositor here instead of leaving the user with an empty desktop.
info "Installing session wrapper /usr/local/bin/chadwm-session..."
sudo tee /usr/local/bin/chadwm-session >/dev/null <<'EOF'
#!/bin/bash
# chadwm session: compositor + wallpaper + status, then hand over to chadwm.
pgrep -x picom >/dev/null || picom --daemon &
if [ -d "$HOME/Pictures" ]; then
feh --bg-fill "$(find "$HOME/Pictures" -maxdepth 1 -type f \
\( -iname '*.jpg' -o -iname '*.png' \) | head -n1)" 2>/dev/null || true
fi
xsetroot -cursor_name left_ptr 2>/dev/null || true
exec chadwm
EOF
sudo chmod 755 /usr/local/bin/chadwm-session
write_x11_session chadwm "chadwm" "/usr/local/bin/chadwm-session"
install_nerd_font JetBrainsMono
install_packages sddm
switch_display_manager sddm
ok "chadwm setup complete. Log out and pick chadwm in SDDM."
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Tiling window manager: Hyprland"
rule
info "Installing Hyprland and its ecosystem..."
install_packages hyprland xdg-desktop-portal-hyprland alacritty
install_packages hyprpaper hypridle hyprlock waybar mako
install_optional wofi
install_optional xwayland-satellite
install_session_prereqs
install_nerd_font JetBrainsMono
# The Fedora hyprland package ships hyprland.desktop in wayland-sessions.
install_packages sddm
switch_display_manager sddm
ok "Hyprland setup complete. Log out and pick Hyprland in SDDM."
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Tiling window manager: MangoWC"
rule
# MangoWC is not in the Fedora repos; it is packaged in Terra.
add_terra_repo
info "Installing MangoWC..."
if ! sudo dnf install -y mangowc; then
err "mangowc is not available from Terra on this release."
err "Alternatives: copr dennemann/MangoWC, or build from source:"
err " https://github.com/GravityShark/mangowc"
exit 1
fi
install_packages fuzzel alacritty
install_optional xdg-desktop-portal-wlr
install_optional xwayland-satellite
install_session_prereqs
install_nerd_font JetBrainsMono
# MangoWC's session entry is not guaranteed by the package; write one if absent.
write_wayland_session mangowc "MangoWC" "mangowc"
install_packages sddm
switch_display_manager sddm
ok "MangoWC setup complete. Log out and pick MangoWC in SDDM."
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/common.sh
source "$HERE/../../lib/common.sh"
# shellcheck source=../../lib/session.sh
source "$HERE/../../lib/session.sh"
if is_debug; then set +e; else set -e; fi
step "Tiling window manager: Niri"
rule
# Noctalia (the shell you settled on) lives in the Terra repo.
add_terra_repo
info "Installing Niri + Noctalia..."
install_packages niri noctalia fuzzel alacritty
# niri is Wayland-only; this lets X11 apps run inside it
install_optional xwayland-satellite
install_optional xdg-desktop-portal-wlr
install_session_prereqs
install_nerd_font JetBrainsMono
# niri ships /usr/share/wayland-sessions/niri.desktop itself, so no entry needed.
install_packages sddm
switch_display_manager sddm
ok "Niri setup complete. Log out and pick Niri in SDDM."
Regular → Executable
+280 -218
View File
@@ -1,263 +1,325 @@
#!/bin/bash #!/bin/bash
#
# setup.sh — unified Fedora configuration
# Target: bare/minimal Fedora 44 and newer
#
set -uo pipefail set -uo pipefail
#------------------------------------------
# Color helpers (printf-safe, no tput)
#------------------------------------------
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
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
#------------------------------------------
pause_if_debug() {
if [[ "${DEBUG_MODE:-false}" == "true" ]]; then
echo
color_yellow "----------------------------------------------------------------"
read -rp "Section complete. Press [Enter] to continue, or [q] to abort: " debug_choice
if [[ "${debug_choice,,}" == "q" ]]; then
color_red "Script aborted by user."
exit 1
fi
color_yellow "----------------------------------------------------------------"
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
if is_package_installed "$pkg"; then
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
#------------------------------------------
#------------------------------------------
# Script Version 1.0
#------------------------------------------
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.0"
color_yellow "----------------------------------------------------------------"
echo
#------------------------------------------
# OS Detection
#------------------------------------------
echo
color_yellow "----------------------------------------------------------------"
color_yellow "Start OS Detection"
color_yellow "----------------------------------------------------------------"
echo
source /etc/os-release
OS_ID="${ID,,}"
OS_LIKE="${ID_LIKE:-}"
OS_LIKE="${OS_LIKE,,}"
OS_VERSION="${VERSION_ID:-unknown}"
OS_PRETTY="$PRETTY_NAME"
OS=""
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/common.sh
source "$SCRIPT_DIR/lib/common.sh"
# shellcheck source=lib/session.sh
source "$SCRIPT_DIR/lib/session.sh"
case "$OS_ID" in #------------------------------------------
fedora) OS="fedora" ;; # Defaults + argument parsing
*) # DEBUG_MODE must be initialised before anything reads it under set -u.
if [[ "$OS_LIKE" == *"fedora"* || "$OS_LIKE" == *"rhel"* ]]; then #------------------------------------------
OS="fedora" DEBUG_MODE=false
fi ASSUME_YES=false
;; DE=""
esac TWM=""
if [[ -n "$OS" ]]; then usage() {
color_cyan "----------------------------------------------------------------" cat <<'EOF'
color_cyan "Detected OS: $OS_PRETTY" setup.sh — unified Fedora configuration (Fedora 44+)
color_cyan "Version: $OS_VERSION"
color_cyan "----------------------------------------------------------------" Usage:
./setup.sh interactive: pick a DE and a TWM
./setup.sh --de=none --twm=niri non-interactive, explicit choices
./setup.sh --debug pause after each section
Options:
--de=NAME gnome | plasma | xfce | none
--twm=NAME chadwm | hyprland | mango | niri | none
-y, --yes never prompt (requires --de and --twm)
-d, --debug pause after each section instead of aborting on error
-h, --help show this help
Valid DE/TWM combinations:
any DE + any TWM DE provides the session, TWM is added alongside it
none + any TWM TWM-only machine, SDDM is installed as the greeter
any DE + none plain desktop, no tiling window manager
none + none refused: that is not a graphical system
Notes:
* chadwm is an X11 window manager; the other three are Wayland compositors.
* Run as your normal user, not root. sudo is used where needed.
EOF
}
for arg in "$@"; do
case "$arg" in
-d|--debug) DEBUG_MODE=true ;;
-y|--yes) ASSUME_YES=true ;;
--de=*) DE="${arg#*=}" ;;
--twm=*) TWM="${arg#*=}" ;;
-h|--help) usage; exit 0 ;;
*)
err "Unknown argument: $arg"
printf "\n"
usage
exit 2
;;
esac
done
export DEBUG_MODE ASSUME_YES
if is_debug; then
set +e # walk through failures instead of dying on the first one
else else
color_red "----------------------------------------------------------------" set -e
color_red "ERROR: Unsupported or unknown Linux distribution." fi
color_red "Detected: ID=$OS_ID ID_LIKE=${OS_LIKE:-empty}"
color_red "----------------------------------------------------------------" #------------------------------------------
# Preconditions
#------------------------------------------
# clear can fail without TERM (cron, piped install, ssh without a tty) and would
# abort the whole run under set -e.
clear 2>/dev/null || true
printf "\n"
color_yellow "----------------------------------------------------------------"
color_yellow "Fedora unified configuration"
color_yellow "----------------------------------------------------------------"
if [[ ${EUID} -eq 0 ]]; then
err "Do not run this as root. Run it as your user; it calls sudo itself."
exit 1 exit 1
fi fi
if [[ "$ASSUME_YES" == "true" && ( -z "$DE" || -z "$TWM" ) ]]; then
err "--yes requires explicit --de and --twm, so nothing is guessed on an"
err "unattended run. Example:"
err " ./setup.sh --yes --de=none --twm=niri"
exit 2
fi
if is_debug; then
color_red "!!! DEBUG MODE ENABLED !!!"
color_red "The script will pause after each section."
fi
#------------------------------------------
# OS gate — Fedora only, 44+
#------------------------------------------
step "OS detection"
rule
# Overridable so the script can be tested on a non-Fedora host.
OS_RELEASE_FILE="${OS_RELEASE_FILE:-/etc/os-release}"
# shellcheck source=/dev/null
source "$OS_RELEASE_FILE"
OS_ID="${ID:-unknown}"; OS_ID="${OS_ID,,}"
OS_PRETTY="${PRETTY_NAME:-unknown}"
if [[ "$OS_ID" != "fedora" ]]; then
err "Unsupported distribution: $OS_PRETTY (ID=${OS_ID})"
err "This repo targets Fedora only. RHEL clones are refused on purpose:"
err "they ship no dnf5 config-manager and no RPM Fusion, so both the base"
err "setup and every module would fail half-way."
exit 1
fi
FEDORA_REL=$(rpm -E %fedora)
if [[ "$FEDORA_REL" =~ ^[0-9]+$ ]] && (( FEDORA_REL < 44 )); then
err "$OS_PRETTY reports release ${FEDORA_REL}, but this setup targets Fedora 44+."
exit 1
fi
ok "Detected: $OS_PRETTY (release ${FEDORA_REL})"
pause_if_debug pause_if_debug
#------------------------------------------ #------------------------------------------
# 1 Basic Settings # 1 Base settings
#------------------------------------------ #------------------------------------------
echo step "1 Base settings"
color_yellow "----------------------------------------------------------------" rule
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 if ! command -v curl >/dev/null 2>&1; then
color_yellow "curl is not installed. Installing..." info "curl missing. Installing..."
install_packages curl install_packages curl
fi fi
pause_if_debug # config-manager lives in dnf5-plugins; every repo step below depends on it.
if ! dnf config-manager --help >/dev/null 2>&1; then
info "dnf config-manager missing. Installing dnf5-plugins..."
install_packages dnf5-plugins
fi
#------------------------------------------ info "Tuning DNF..."
# 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 max_parallel_downloads=20
sudo dnf config-manager setopt defaultyes=True sudo dnf config-manager setopt defaultyes=True
color_green "DNF optimized. Refreshing metadata..." info "Refreshing metadata..."
sudo dnf makecache --refresh sudo dnf makecache --refresh
color_cyan "Enabling RPM Fusion repositories for Fedora $(rpm -E %fedora)..." add_rpmfusion_repo
pause_if_debug
# Define the version variable for readability if ! command -v flatpak >/dev/null 2>&1; then
FEDORA_VER=$(rpm -E %fedora) info "Flatpak missing. Installing..."
install_packages flatpak
fi
info "Ensuring Flathub is available (system-wide)..."
sudo flatpak remote-add --if-not-exists --system flathub https://dl.flathub.org/repo/flathub.flatpakrepo
color_yellow "Checking for updates and sources..." info "Updating the system..."
sudo dnf check-update || true sudo dnf update -y
pause_if_debug
# Check if flatpak is installed, if not, install it #------------------------------------------
if ! command -v flatpak &> /dev/null; then # 2 Menu helpers
color_yellow "Flatpak not found. Installing..." #------------------------------------------
sudo dnf install -y flatpak # $1 = prompt, $2 = default answer, rest = valid answers
ask_choice() {
local prompt="$1" default="$2"; shift 2
local answer
if [[ "$ASSUME_YES" == "true" ]]; then
echo "$default"
return 0
fi
while true; do
if ! read -t 60 -rp "$prompt (default: $default): " answer; then
printf "\n"
answer=""
fi
answer="${answer:-$default}"
answer="${answer,,}"
local v
for v in "$@"; do
if [[ "$answer" == "$v" ]]; then
echo "$answer"
return 0
fi
done
err "Invalid option: '$answer'. Choose from: $*"
done
}
#------------------------------------------
# 3 Desktop environment selection
#------------------------------------------
if [[ -z "$DE" ]]; then
step "3 Desktop environment"
rule
printf "\n"
color_gray " This system is treated as a bare Fedora install — picking a DE"
color_gray " here is what gives you a graphical login."
printf "\n"
echo " 1) GNOME (gdm)"
echo " 2) Plasma (sddm)"
echo " 3) XFCE (lightdm)"
echo " 4) None (TWM only — SDDM will be installed by the TWM module)"
printf "\n"
choice=$(ask_choice "Select desktop environment [1/2/3/4]" "1" 1 2 3 4)
case "$choice" in
1) DE="gnome" ;;
2) DE="plasma" ;;
3) DE="xfce" ;;
4) DE="none" ;;
esac
fi fi
color_cyan "Enabling Flathub..." case "$DE" in
# Using --if-not-exists is good practice to prevent errors on re-runs gnome|plasma|xfce|none) ;;
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo *) err "Unknown --de value: '$DE' (gnome|plasma|xfce|none)"; exit 2 ;;
esac
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 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"
echohttps://git.ku-it.org/terrabeam/starburst.git
sudo dnf update -y
pause_if_debug pause_if_debug
#------------------------------------------ #------------------------------------------
# Tiling Window Manager Selection # 4 Tiling window manager selection
#------------------------------------------ #------------------------------------------
echo if [[ -z "$TWM" ]]; then
color_yellow "----------------------------------------------------------------" step "4 Tiling window manager"
color_yellow "Tiling WM Selection" rule
color_yellow "----------------------------------------------------------------" printf "\n"
echo echo " 1) Niri (Wayland, scrollable)"
echo " 2) Hyprland (Wayland, dynamic)"
while true; do echo " 3) MangoWC (Wayland, dwl-based, Terra repo)"
echo echo " 4) chadwm (X11, dwm fork, built from source)"
color_gray "Select a tiling window manager:" echo " 5) None"
echo printf "\n"
echo " 1) CHADWM" choice=$(ask_choice "Select tiling window manager [1/2/3/4/5]" "1" 1 2 3 4 5)
echo " 2) Hyprland" case "$choice" in
echo " 3) MangoWC" 1) TWM="niri" ;;
echo " 4) Niri" 2) TWM="hyprland" ;;
echo " x) None (default)" 3) TWM="mango" ;;
if ! read -t 15 -rp "Enter choice [1/2/3/4/x] (default: x): " choice; then 4) TWM="chadwm" ;;
choice="x" 5) TWM="none" ;;
fi
case "${choice,,}" in
1) TWM="chadwm"; break ;;
2) TWM="hyprland"; break ;;
3) TWM="mango"; break ;;
4) TWM="niri"; break ;;
x|"") TWM="none"; break ;;
*) echo "Invalid option. Please enter 1, 2, 3, 4 or x." ;;
esac esac
done fi
echo
color_cyan "----------------------------------------------------------------"
color_cyan "Selected Tiling WM: $TWM"
color_cyan "----------------------------------------------------------------"
pause_if_debug
#------------------------------------------
# 5. Tiling Window Manager installation
#------------------------------------------
case "$TWM" in case "$TWM" in
chadwm|hyprland|mango|niri) niri|hyprland|mango|chadwm|none) ;;
color_yellow "Installing $TWM" *) err "Unknown --twm value: '$TWM' (niri|hyprland|mango|chadwm|none)"; exit 2 ;;
SCRIPT_NAME="$SCRIPT_DIR/${TWM}.sh"
if [[ -f "$SCRIPT_NAME" ]]; then
color_cyan "Running $SCRIPT_NAME"
source "$SCRIPT_NAME"
else
color_red "Error: $SCRIPT_NAME not found!"
exit 1
fi
;;
none)
color_gray "No tiling window manager selected, skipping TWM installation."
;;
esac esac
ok "Selection: DE=${DE} TWM=${TWM}"
# A bare install with neither is not a graphical system. Refuse rather than
# leave the user with a machine that boots to a black screen.
if [[ "$DE" == "none" && "$TWM" == "none" ]]; then
err "DE=none with TWM=none would leave no graphical session at all."
err "Pick a desktop environment, a tiling window manager, or both."
exit 2
fi
pause_if_debug pause_if_debug
echo #------------------------------------------
color_yellow "----------------------------------------------------------------" # 5 Dispatch
color_yellow "End Detection" #------------------------------------------
color_yellow "----------------------------------------------------------------" export DE TWM
color_green "Fedora setup complete." run_module() {
color_red "The installation has finished. A reboot is recommended." local path="$1"
# Reboots are dangerous to automate; we use a shorter timeout and default to No if [[ ! -f "$path" ]]; then
if read -t 10 -rp "Reboot now? [y/N]: " reboot_choice; then err "Module not found: $path"
return 1
fi
info "Running $(basename "$path")"
printf "\n"
# Separate process: a module's own shell options and exit codes stay its own.
bash "$path"
}
step "5 Installation"
rule
if [[ "$DE" != "none" ]]; then
run_module "$SCRIPT_DIR/modules/de/${DE}.sh"
pause_if_debug
fi
if [[ "$TWM" != "none" ]]; then
run_module "$SCRIPT_DIR/modules/twm/${TWM}.sh"
pause_if_debug
fi
#------------------------------------------
# 6 Done
#------------------------------------------
step "6 Summary"
rule
ok "DE: $DE"
ok "TWM: $TWM"
DM=$(detect_display_manager)
ok "Display manager: ${DM:-none}"
if [[ -z "$DM" ]]; then
warn "No display manager is active. You will boot to a text console."
warn "Install one, or run a TWM module which sets up SDDM."
fi
printf "\n"
color_green "Fedora setup complete. A reboot is recommended."
if [[ "$ASSUME_YES" == "true" ]]; then
info "Unattended run: not rebooting."
exit 0
fi
if read -t 15 -rp "Reboot now? [y/N]: " reboot_choice; then
case "${reboot_choice,,}" in case "${reboot_choice,,}" in
y|yes) y|yes)
color_red "Rebooting now." color_red "Rebooting now."