From 3d2dbfa06aa6159cf1a14c24fd31d756971d6b03 Mon Sep 17 00:00:00 2001
From: humocs-man <251756307+humocs-man@users.noreply.github.com>
Date: Fri, 13 Mar 2026 13:24:12 +0100
Subject: [PATCH] Refactor firstboot-setup.sh for clarity and updates
---
.../skel/.config/firstboot/firstboot-setup.sh | 259 +++++++++---------
1 file changed, 126 insertions(+), 133 deletions(-)
diff --git a/files/etc/skel/.config/firstboot/firstboot-setup.sh b/files/etc/skel/.config/firstboot/firstboot-setup.sh
index 2fe3835..dd5109d 100644
--- a/files/etc/skel/.config/firstboot/firstboot-setup.sh
+++ b/files/etc/skel/.config/firstboot/firstboot-setup.sh
@@ -5,47 +5,49 @@ LOG="$HOME/.local/state/firstboot-setup.log"
mkdir -p "$(dirname "$LOG")"
exec > >(tee -a "$LOG") 2>&1
-# ----------------------------
+# ------------------------------------------------------------
# Session check
-# ----------------------------
+# ------------------------------------------------------------
if [[ -z "${WAYLAND_DISPLAY:-}" && -z "${DISPLAY:-}" ]]; then
echo "Keine grafische Session verfügbar – breche ab."
exit 1
fi
-# ----------------------------
-# Cleanup trap (nur bei Fehlern)
-# ----------------------------
-cleanup() {
- local code=$?
- if [[ $code -ne 0 ]]; then
- echo "Wizard abgebrochen oder mit Fehler beendet (Exitcode: $code)."
- rm -f "$HOME/.config/firstboot/run"
- systemctl --user disable firstboot-setup.service || true
- fi
-}
-trap cleanup EXIT
-
-# ----------------------------
-# Abort dialog
-# ----------------------------
+# ------------------------------------------------------------
+# Globaler Abbruch – beendet den Wizard vollständig
+# ------------------------------------------------------------
abort() {
- local code=$?
- echo "Abort ausgelöst (Exitcode: $code)."
+ echo "Abbruch durch Benutzer."
zenity --question \
--title="Setup abbrechen?" \
--text="Setup abbrechen?\n
-Der Einrichtungs-Assistent wird dann nicht erneut angezeigt.\n
-Alle Anwendungen können jederzeit über den COSMIC-Shop installiert oder entfernt werden.\n
-Möchtest du den Setup-Assistenten wirklich abbrechen?" || return 0
+Der Einrichtungs‑Assistent wird dann nicht erneut angezeigt.\n
+Alle Anwendungen können jederzeit über den COSMIC‑Shop installiert oder entfernt werden.\n
+Möchtest du den Setup‑Assistenten wirklich abbrechen?" \
+ >/dev/null 2>&1 || true
+ rm -f "$HOME/.config/firstboot/run"
+ systemctl --user disable firstboot-setup.service >/dev/null 2>&1 || true
exit 0
}
-# ----------------------------
-# Helper functions
-# ----------------------------
+# ------------------------------------------------------------
+# Cleanup bei Fehlern
+# ------------------------------------------------------------
+cleanup() {
+ local code=$?
+ if [[ $code -ne 0 ]]; then
+ echo "Wizard mit Fehler beendet (Exitcode: $code)."
+ rm -f "$HOME/.config/firstboot/run"
+ systemctl --user disable firstboot-setup.service >/dev/null 2>&1 || true
+ fi
+}
+trap cleanup EXIT
+
+# ------------------------------------------------------------
+# Helper
+# ------------------------------------------------------------
ensure_flathub() {
flatpak remote-list --columns=name 2>/dev/null | grep -qx flathub || \
flatpak remote-add --if-not-exists flathub \
@@ -54,7 +56,8 @@ ensure_flathub() {
install_brew_and_setup_path() {
if ! command -v brew >/dev/null 2>&1; then
- NONINTERACTIVE=1 CI=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+ NONINTERACTIVE=1 CI=1 /bin/bash -c \
+ "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
local BREW_PREFIX="/home/linuxbrew/.linuxbrew"
@@ -73,149 +76,162 @@ install_brew_and_setup_path() {
done
}
+# ------------------------------------------------------------
+# Zenity‑Checkliste
+# Erwartet Paare: id "beschreibung"
+# ------------------------------------------------------------
choose_list() {
local title="$1"
local text="$2"
shift 2
+ if (( $# % 2 != 0 )); then
+ echo "choose_list: Ungerade Anzahl Argumente (id/beschreibung Paare erwartet)." >&2
+ exit 1
+ fi
+
+ local -a rows=()
+ while (( $# )); do
+ rows+=(FALSE "$1" "$2")
+ shift 2
+ done
+
local result
result=$(zenity --list \
--title="$title" \
--text="$text" \
--checklist \
--column="Auswahl" \
- --column="ID" \
+ --column="Anwendung" \
--column="Beschreibung" \
- FALSE "$@" \
--separator="|" \
+ "${rows[@]}" \
) || abort
echo "${result:-}"
}
-# ----------------------------
+# ------------------------------------------------------------
# Welcome
-# ----------------------------
+# ------------------------------------------------------------
zenity --info \
--title="Willkommen bei COSMIC" \
--text="Willkommen bei COSMIC\n
Dieser Assistent hilft dir beim Einstieg in dein System.\n
Hinweise:\n
-• Alle Anwendungen können später jederzeit über den COSMIC-Shop installiert oder entfernt werden.\n
+• Alle Anwendungen können später jederzeit über den COSMIC‑Shop installiert oder entfernt werden.\n
• Der Assistent ist optional und erscheint nur einmal.\n
• Die Auswahl deckt gängige Anwendungen ab, aber nicht alles." \
|| abort
-# ----------------------------
+# ------------------------------------------------------------
# Auswahl
-# ----------------------------
+# ------------------------------------------------------------
BROWSERS=$(choose_list \
"Browser" \
"Browser auswählen\nWähle einen oder mehrere Webbrowser aus." \
- firefox "Mozilla Firefox (empfohlen)" \
- chromium "Chromium (Open-Source Basis)" \
- brave "Brave (datenschutzorientiert)" \
+ firefox "Ausgewogen, weit verbreitet, guter Datenschutz" \
+ chromium "Schlank, schnell, Open‑Source‑Basis vieler Browser" \
+ brave "Starker Fokus auf Datenschutz und Werbeblockierung" \
)
OFFICE=$(choose_list \
- "Office & Dokumente" \
- "Office & Dokumente\nWähle Anwendungen für Büroarbeit und PDFs." \
- libreoffice "LibreOffice (Office-Suite)" \
- onlyoffice "OnlyOffice (MS-Office-ähnlich)" \
- collabora "Collabora Office" \
- papers "Papers (PDF-Viewer)" \
- simplescan "Simple Scan" \
+ "Office & Dokumente" \
+ "Office & Dokumente\nAnwendungen für Büroarbeit und PDFs." \
+ libreoffice "Umfangreiche Office‑Suite für lokale Dokumente" \
+ onlyoffice "Moderne Oberfläche, hohe MS‑Office‑Kompatibilität" \
+ collabora "LibreOffice‑Technologie mit Fokus auf Zusammenarbeit" \
+ papers "Leichter PDF‑Viewer zum Lesen und Kommentieren" \
+ simplescan "Einfaches Scannen von Dokumenten und Bildern" \
)
GRAPHICS=$(choose_list \
- "Grafik & Kreativ" \
- "Grafik & Kreativ\nWerkzeuge für Bildbearbeitung und Illustration." \
- gimp "GIMP" \
- krita "Krita" \
- inkscape "Inkscape" \
+ "Grafik & Kreativ" \
+ "Grafik & Kreativ\nWerkzeuge für Bildbearbeitung und Illustration." \
+ gimp "Leistungsstarke Bildbearbeitung für Fotos" \
+ krita "Digitale Malerei und Illustration" \
+ inkscape "Vektorgrafiken für Logos und Icons" \
)
MEDIA=$(choose_list \
- "Medien & Unterhaltung" \
- "Medien & Unterhaltung\nAudio- und Video-Wiedergabe." \
- vlc "VLC Media Player" \
- showtime "Gnome Video Player" \
- spotify "Spotify Client" \
+ "Medien & Unterhaltung" \
+ "Medien & Unterhaltung\nAudio‑ und Video‑Wiedergabe." \
+ vlc "Spielt nahezu alle Audio‑ und Videoformate ab" \
+ showtime "Einfacher Videoplayer mit klarer Oberfläche" \
+ spotify "Streaming‑Dienst für Musik und Podcasts" \
)
AV=$(choose_list \
- "Audio & Video-Bearbeitung" \
- "Audio & Video-Bearbeitung\nWerkzeuge für kreative Medienproduktion." \
- shotcut "Shotcut" \
- kdenlive "Kdenlive" \
- audacity "Audacity" \
- ardour "Ardour" \
+ "Audio & Video‑Bearbeitung" \
+ "Audio & Video‑Bearbeitung\nWerkzeuge für kreative Medienproduktion." \
+ shotcut "Einfacher Videoeditor für schnelle Projekte" \
+ kdenlive "Umfangreicher Videoeditor mit vielen Effekten" \
+ audacity "Aufnahme und Bearbeitung von Audio" \
+ ardour "Professionelle Audio‑Produktion" \
)
GAMES=$(choose_list \
"Spiele" \
- "Spiele-Plattformen\nWähle Plattformen für PC-Spiele." \
- steam "Steam" \
- lutris "Lutris" \
+ "Spiele‑Plattformen\nPlattformen für PC‑Spiele." \
+ steam "Große Spielebibliothek und Community‑Funktionen" \
+ lutris "Zentrale Verwaltung von Spielen aus vielen Quellen" \
)
MAIL=$(choose_list \
- "E-Mail" \
- "E-Mail-Programme\nWähle einen oder mehrere Mail-Clients." \
- thunderbird "Thunderbird" \
- geary "Geary" \
- evolution "Evolution" \
+ "E‑Mail" \
+ "E‑Mail‑Programme\nDesktop‑Clients für E‑Mail und Kalender." \
+ thunderbird "Leistungsstarker Mail‑Client mit Erweiterungen" \
+ geary "Schlanker Mail‑Client mit einfacher Bedienung" \
+ evolution "E‑Mail, Kalender und Kontakte in einer Anwendung" \
)
DEV=$(choose_list \
"Entwicklung" \
- "Entwicklung\nWerkzeuge für Software-Entwicklung." \
- vscode "Visual Studio Code" \
+ "Entwicklung\nWerkzeuge für Software‑Entwicklung." \
+ vscode "Beliebter Code‑Editor mit vielen Erweiterungen" \
)
SYSTEM=$(choose_list \
- "System-Werkzeuge" \
- "System-Werkzeuge\nHilfsprogramme für Konfiguration und Verwaltung." \
- flatseal "Flatseal" \
+ "System‑Werkzeuge" \
+ "System‑Werkzeuge\nHilfsprogramme für Konfiguration und Verwaltung." \
+ flatseal "Verwaltung von Flatpak‑Berechtigungen" \
)
-# ----------------------------
+# ------------------------------------------------------------
# Homebrew
-# ----------------------------
+# ------------------------------------------------------------
zenity --question \
--title="Homebrew (optional)" \
--text="Homebrew installieren?\n
-Homebrew ist ein zusätzlicher Paketmanager für Entwickler- und CLI-Werkzeuge.\n
+Zusätzlicher Paketmanager für Entwickler‑ und CLI‑Werkzeuge.\n
• Installation im Benutzerverzeichnis\n
• Keine Änderung am Basissystem\n
-• Komplett optional"
-
+• Komplett optional" \
+ || true
USE_BREW=$([[ $? -eq 0 ]] && echo yes || echo no)
-# ----------------------------
-# Auto-Update
-# ----------------------------
+# ------------------------------------------------------------
+# Auto‑Update
+# ------------------------------------------------------------
zenity --question \
--title="Automatische Systemaktualisierung" \
--text="Automatische Updates aktivieren?\n
-Wenn aktiviert, prüft das System einmal pro Woche auf neue Aktualisierungen und installiert sie automatisch.\n
-Manuelle Aktualisierung:\n
-bootc upgrade\n
-Dienst manuell starten:\n
-systemctl --user start bootc-update.service"
-
+Wöchentliche Prüfung und Installation von System‑Updates.\n
+Manuell:\n
+bootc upgrade" \
+ || true
AUTO_UPDATE=$([[ $? -eq 0 ]] && echo yes || echo no)
-# ----------------------------
-# Summary
-# ----------------------------
+# ------------------------------------------------------------
+# Zusammenfassung
+# ------------------------------------------------------------
SUMMARY="Browser: ${BROWSERS:-keine}
Office: ${OFFICE:-keine}
Grafik: ${GRAPHICS:-keine}
Medien: ${MEDIA:-keine}
Audio/Video: ${AV:-keine}
Spiele: ${GAMES:-keine}
-E-Mail: ${MAIL:-keine}
+E‑Mail: ${MAIL:-keine}
Entwicklung: ${DEV:-keine}
System: ${SYSTEM:-keine}
@@ -227,15 +243,15 @@ zenity --question \
--text="Bitte bestätige die Installation\n\n$SUMMARY" \
|| abort
-# ----------------------------
+# ------------------------------------------------------------
# Installation
-# ----------------------------
+# ------------------------------------------------------------
ensure_flathub
(
- echo "10"; echo "# Installiere Browser..."
+ echo "10"; echo "# Installiere Anwendungen…"
+
for b in ${BROWSERS//|/ }; do
- [[ -z "$b" ]] && continue
case "$b" in
firefox) flatpak install -y flathub org.mozilla.firefox ;;
chromium) flatpak install -y flathub org.chromium.Chromium ;;
@@ -243,9 +259,7 @@ ensure_flathub
esac
done
- echo "25"; echo "# Installiere Office..."
for o in ${OFFICE//|/ }; do
- [[ -z "$o" ]] && continue
case "$o" in
libreoffice) flatpak install -y flathub org.libreoffice.LibreOffice ;;
onlyoffice) flatpak install -y flathub org.onlyoffice.desktopeditors ;;
@@ -255,9 +269,7 @@ ensure_flathub
esac
done
- echo "40"; echo "# Installiere Grafik-Tools..."
for g in ${GRAPHICS//|/ }; do
- [[ -z "$g" ]] && continue
case "$g" in
gimp) flatpak install -y flathub org.gimp.GIMP ;;
krita) flatpak install -y flathub org.kde.krita ;;
@@ -265,19 +277,15 @@ ensure_flathub
esac
done
- echo "55"; echo "# Installiere Medien..."
for m in ${MEDIA//|/ }; do
- [[ -z "$m" ]] && continue
case "$m" in
vlc) flatpak install -y flathub org.videolan.VLC ;;
- spotify) flatpak install -y flathub com.spotify.Client ;;
showtime) flatpak install -y flathub org.gnome.Showtime ;;
+ spotify) flatpak install -y flathub com.spotify.Client ;;
esac
done
- echo "70"; echo "# Installiere Audio/Video-Tools..."
for a in ${AV//|/ }; do
- [[ -z "$a" ]] && continue
case "$a" in
shotcut) flatpak install -y flathub org.shotcut.Shotcut ;;
kdenlive) flatpak install -y flathub org.kde.kdenlive ;;
@@ -286,18 +294,14 @@ ensure_flathub
esac
done
- echo "85"; echo "# Installiere Spiele-Plattformen..."
for g in ${GAMES//|/ }; do
- [[ -z "$g" ]] && continue
case "$g" in
steam) flatpak install -y flathub com.valvesoftware.Steam ;;
lutris) flatpak install -y flathub net.lutris.Lutris ;;
esac
done
- echo "90"; echo "# Installiere E-Mail-Clients..."
for m in ${MAIL//|/ }; do
- [[ -z "$m" ]] && continue
case "$m" in
thunderbird) flatpak install -y flathub org.mozilla.Thunderbird ;;
geary) flatpak install -y flathub org.gnome.Geary ;;
@@ -305,50 +309,39 @@ ensure_flathub
esac
done
- echo "95"; echo "# Installiere Entwicklung..."
for d in ${DEV//|/ }; do
- [[ -z "$d" ]] && continue
- case "$d" in
- vscode) flatpak install -y flathub com.visualstudio.code ;;
- esac
+ [[ "$d" == vscode ]] && flatpak install -y flathub com.visualstudio.code
done
- echo "97"; echo "# Installiere System-Werkzeuge..."
for s in ${SYSTEM//|/ }; do
- [[ -z "$s" ]] && continue
- case "$s" in
- flatseal) flatpak install -y flathub com.github.tchx84.Flatseal ;;
- esac
+ [[ "$s" == flatseal ]] && flatpak install -y flathub com.github.tchx84.Flatseal
done
- echo "98"; echo "# Homebrew..."
[[ "$USE_BREW" == yes ]] && install_brew_and_setup_path
echo "100"; echo "# Fertig."
) | zenity --progress \
--title="Installation läuft" \
- --text="Bitte warten..." \
+ --text="Bitte warten…" \
--percentage=0 \
--auto-close
-# ----------------------------
-# Auto-Update aktivieren
-# ----------------------------
-if [[ "$AUTO_UPDATE" == yes ]]; then
- systemctl --user enable --now bootc-update.timer
-fi
+# ------------------------------------------------------------
+# Auto‑Update aktivieren
+# ------------------------------------------------------------
+[[ "$AUTO_UPDATE" == yes ]] && systemctl --user enable --now bootc-update.timer || true
-# ----------------------------
-# Wizard done (sauberer Abschluss)
-# ----------------------------
+# ------------------------------------------------------------
+# Wizard done
+# ------------------------------------------------------------
trap - EXIT
rm -f "$HOME/.config/firstboot/run"
-systemctl --user disable firstboot-setup.service || true
+systemctl --user disable firstboot-setup.service >/dev/null 2>&1 || true
zenity --info \
--title="Fertig" \
--text="Die Einrichtung ist abgeschlossen.\n
-Weitere Anwendungen kannst du jederzeit über den COSMIC-Shop installieren.\n
+Weitere Anwendungen kannst du jederzeit über den COSMIC‑Shop installieren.\n
Homebrew aktualisieren:\n
-brew update && brew upgrade\n
-Der Setup-Assistent wird nicht erneut gestartet."
+brew update && brew upgrade\n
+Der Setup‑Assistent wird nicht erneut gestartet."