diff --git a/configs/baseline/airootfs/etc/calamares/branding/fws/desktop.qml b/configs/baseline/airootfs/etc/calamares/branding/fws/desktop.qml new file mode 100644 index 0000000..e1e59d9 --- /dev/null +++ b/configs/baseline/airootfs/etc/calamares/branding/fws/desktop.qml @@ -0,0 +1,44 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import calamares 1.0 + +Page { + id: page + title: qsTr("Choix de l'environnement") + + Column { + anchors.fill: parent + anchors.margins: 20 + spacing: 12 + + Text { + text: qsTr("Choisissez l'environnement de bureau à installer :") + font.pixelSize: 20 + color: "#00d4ff" + } + + RadioButton { id: rb_xfce; text: "Xfce"; checked: true; onCheckedChanged: if (checked) saveChoice() } + RadioButton { id: rb_kde; text: "KDE"; onCheckedChanged: if (checked) saveChoice() } + RadioButton { id: rb_gnome; text: "GNOME"; onCheckedChanged: if (checked) saveChoice() } + RadioButton { id: rb_hypr; text: "Hyprland"; onCheckedChanged: if (checked) saveChoice() } + + Button { + text: qsTr("Enregistrer le choix") + onClicked: saveChoice() + } + + function saveChoice() { + var choice = rb_xfce.checked ? "xfce" : (rb_kde.checked ? "kde" : (rb_gnome.checked ? "gnome" : "hyprland")) + try { + calamares.globalStorage.insert("FWS_DESKTOP", choice) + } catch (e) { + // ignore if unavailable + } + try { + calamares.utils.runCommand("/bin/sh", ["-c", "printf '%s' \"" + choice + "\" > /run/fws-desktop"], true) + } catch (e) { + // best effort + } + } + } +} diff --git a/configs/baseline/airootfs/etc/calamares/modules/desktop.conf b/configs/baseline/airootfs/etc/calamares/modules/desktop.conf new file mode 100644 index 0000000..e731b60 --- /dev/null +++ b/configs/baseline/airootfs/etc/calamares/modules/desktop.conf @@ -0,0 +1,8 @@ +--- +# Minimal Calamares view module config for desktop selection +# This tells Calamares to use our QML page from the branding folder. +module: view +name: desktop +qml: "branding/fws/desktop.qml" +title: "Choix de l'environnement" +description: "Sélectionne le bureau à installer" diff --git a/configs/baseline/airootfs/etc/calamares/modules/services-systemd.conf b/configs/baseline/airootfs/etc/calamares/modules/services-systemd.conf index d12bc78..491c59c 100644 --- a/configs/baseline/airootfs/etc/calamares/modules/services-systemd.conf +++ b/configs/baseline/airootfs/etc/calamares/modules/services-systemd.conf @@ -12,10 +12,6 @@ units: action: "enable" mandatory: false - - name: "lightdm.service" - action: "enable" - mandatory: true - - name: "sshd.service" action: "enable" mandatory: false diff --git a/configs/baseline/airootfs/etc/calamares/modules/shellprocess.conf b/configs/baseline/airootfs/etc/calamares/modules/shellprocess.conf index 42c9fc9..2064ce4 100644 --- a/configs/baseline/airootfs/etc/calamares/modules/shellprocess.conf +++ b/configs/baseline/airootfs/etc/calamares/modules/shellprocess.conf @@ -8,14 +8,13 @@ dontChroot: true script: # Copie le kernel depuis l'ISO vers /boot du système cible - 'cp "$(find /run/archiso/bootmnt -name vmlinuz-linux 2>/dev/null | head -1)" "${ROOT}/boot/vmlinuz-linux"' - - # Configure LightDM pour démarrer automatiquement la session XFCE du premier utilisateur créé. - - 'FIRST_USER="$(awk -F: ''$$3 >= 1000 && $$1 != "nobody" { print $$1; exit }'' "${ROOT}/etc/passwd")"' - - 'if [ -n "$$FIRST_USER" ]; then mkdir -p "${ROOT}/etc/lightdm/lightdm.conf.d"; printf ''[Seat:*]\nautologin-user=%s\nautologin-user-timeout=0\nuser-session=xfce\nautologin-session=xfce\ngreeter-hide-users=true\nallow-guest=false\n'' "$$FIRST_USER" > "${ROOT}/etc/lightdm/lightdm.conf.d/50-fws.conf"; fi' - - 'if [ -n "$$FIRST_USER" ] && [ -d "${ROOT}/home/$$FIRST_USER" ]; then printf ''[Desktop]\nSession=xfce\n'' > "${ROOT}/home/$$FIRST_USER/.dmrc"; fi' + - 'DESKTOP="$(cat /run/fws-desktop 2>/dev/null || printf xfce)"' + - 'if [ -z "$DESKTOP" ]; then DESKTOP="xfce"; fi' + - 'if [ ! -f "${ROOT}/usr/local/bin/fws-desktop-init-$DESKTOP" ]; then echo "Script bureau introuvable: $DESKTOP" >&2; exit 1; fi' + - 'chroot "${ROOT}" /bin/bash "/usr/local/bin/fws-desktop-init-$DESKTOP"' # Supprime le drop-in archiso (surcharge HOOKS avec des hooks inexistants post-install) - - '-rm -f "${ROOT}/etc/mkinitcpio.conf.d/archiso.conf"' + - 'rm -f "${ROOT}/etc/mkinitcpio.conf.d/archiso.conf"' # Remplace le linux.preset archiso par le preset standard (default + fallback) # \x27 = ' et \x22 = " pour éviter les conflits de quotes dans YAML/bash diff --git a/configs/baseline/airootfs/etc/calamares/settings.conf b/configs/baseline/airootfs/etc/calamares/settings.conf index 5cbeae7..6775d1b 100644 --- a/configs/baseline/airootfs/etc/calamares/settings.conf +++ b/configs/baseline/airootfs/etc/calamares/settings.conf @@ -12,6 +12,7 @@ sequence: - keyboard - partition - users + - desktop - summary - exec: - partition diff --git a/configs/baseline/packages.x86_64 b/configs/baseline/packages.x86_64 index f94ce57..4c85b8f 100644 --- a/configs/baseline/packages.x86_64 +++ b/configs/baseline/packages.x86_64 @@ -61,6 +61,7 @@ wget zsh grml-zsh-config bash +zenity nano vim less diff --git a/configs/releng/airootfs/usr/bin/fws-installer b/configs/releng/airootfs/usr/bin/fws-installer index 42e6001..f16c161 100644 --- a/configs/releng/airootfs/usr/bin/fws-installer +++ b/configs/releng/airootfs/usr/bin/fws-installer @@ -4,8 +4,10 @@ # Script de lancement de Calamares # ============================================================ +set -euo pipefail + # Vérifie que Calamares est installé -if ! command -v calamares &>/dev/null; then +if ! command -v calamares >/dev/null 2>&1; then echo "ERREUR : calamares n'est pas installé." exit 1 fi @@ -15,17 +17,91 @@ if [ ! -d /run/archiso ]; then echo "ATTENTION : Ce script doit être lancé depuis le live FWS." fi +choose_desktop() { + local selection + + if command -v zenity >/dev/null 2>&1; then + selection=$(zenity --list \ + --title="Choix de l'environnement" \ + --width=520 \ + --height=320 \ + --radiolist \ + --print-column=2 \ + --column="Choisir" --column="Environnement" --column="Description" \ + TRUE "xfce" "Léger et classique" \ + FALSE "kde" "KDE Plasma" \ + FALSE "gnome" "GNOME" \ + FALSE "hyprland" "Wayland / Hyprland" \ + --text="Sélectionne l'environnement desktop à installer") || exit 1 + + printf '%s' "$selection" + return 0 + fi + + printf 'xfce' +} + +DESKTOP="${FWS_DESKTOP:-xfce}" +DESKTOP_EXPLICIT=0 +CALAMARES_ARGS=() + +while [ "$#" -gt 0 ]; do + case "$1" in + -d|--desktop) + shift + DESKTOP="${1:-xfce}" + DESKTOP_EXPLICIT=1 + ;; + --desktop=*) + DESKTOP="${1#*=}" + DESKTOP_EXPLICIT=1 + ;; + *) + CALAMARES_ARGS+=("$1") + ;; + esac + shift || true +done + +if [ "$DESKTOP_EXPLICIT" -eq 0 ] && [ -z "${FWS_DESKTOP:-}" ]; then + DESKTOP="$(choose_desktop)" +fi + +case "$DESKTOP" in + xfce|kde|gnome|hyprland) + export FWS_DESKTOP="$DESKTOP" + ;; + *) + echo "Environnement invalide: $DESKTOP" + exit 1 + ;; +esac + # Lance Calamares avec les droits root # -D6 active les logs de debug (retirer en production) if [ "$EUID" -ne 0 ]; then if command -v sudo >/dev/null 2>&1; then - exec sudo -E calamares "$@" + # Persist the chosen desktop for Calamares (read by shellprocess before chroot) + if [ -n "${FWS_DESKTOP:-}" ]; then + mkdir -p /run + printf '%s' "$FWS_DESKTOP" > /run/fws-desktop + fi + exec sudo -E calamares "${CALAMARES_ARGS[@]}" elif command -v pkexec >/dev/null 2>&1; then - exec pkexec calamares "$@" + if [ -n "${FWS_DESKTOP:-}" ]; then + mkdir -p /run + printf '%s' "$FWS_DESKTOP" > /run/fws-desktop + fi + exec pkexec calamares "${CALAMARES_ARGS[@]}" else echo "ERREUR : Impossible de lancer Calamares en tant que root (sudo/pkexec non trouvés)." exit 1 fi else - exec calamares "$@" + if [ -n "${FWS_DESKTOP:-}" ]; then + mkdir -p /run + printf '%s' "$FWS_DESKTOP" > /run/fws-desktop + fi + exec calamares "${CALAMARES_ARGS[@]}" fi + diff --git a/configs/releng/airootfs/usr/local/bin/fws-desktop-init-common b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-common new file mode 100644 index 0000000..c52910b --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-common @@ -0,0 +1,56 @@ +#!/bin/bash +set -euo pipefail + +fws_first_user() { + awk -F: '$3 >= 1000 && $1 != "nobody" { print $1; exit }' /etc/passwd +} + +fws_install_packages() { + pacman -Sy --noconfirm --needed "$@" +} + +fws_enable_services() { + for service in "$@"; do + systemctl enable "$service" >/dev/null 2>&1 || true + done +} + + +fws_disable_services() { + for service in "$@"; do + systemctl disable "$service" >/dev/null 2>&1 || true + done +} + +fws_write_dmrc() { + local user_name="$1" + local session_name="$2" + + if [ -n "$user_name" ] && [ -d "/home/$user_name" ]; then + printf '[Desktop]\nSession=%s\n' "$session_name" > "/home/$user_name/.dmrc" + fi +} + +fws_write_lightdm_config() { + local user_name="$1" + local session_name="$2" + + if [ -z "$user_name" ]; then + return 0 + fi + + mkdir -p /etc/lightdm/lightdm.conf.d + printf '[Seat:*]\nautologin-user=%s\nautologin-user-timeout=0\nuser-session=%s\nautologin-session=%s\ngreeter-hide-users=true\nallow-guest=false\n' "$user_name" "$session_name" "$session_name" > /etc/lightdm/lightdm.conf.d/50-fws.conf +} + +fws_write_sddm_config() { + local user_name="$1" + local session_name="$2" + + if [ -z "$user_name" ]; then + return 0 + fi + + mkdir -p /etc/sddm.conf.d + printf '[Autologin]\nUser=%s\nSession=%s.desktop\nRelogin=false\n' "$user_name" "$session_name" > /etc/sddm.conf.d/50-fws.conf +} \ No newline at end of file diff --git a/configs/releng/airootfs/usr/local/bin/fws-desktop-init-gnome b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-gnome new file mode 100644 index 0000000..4d3ed8b --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-gnome @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +. /usr/local/bin/fws-desktop-init-common + +first_user="$(fws_first_user)" + +fws_install_packages gnome sddm +fws_disable_services lightdm.service gdm.service +fws_enable_services sddm.service +fws_write_sddm_config "$first_user" gnome +fws_write_dmrc "$first_user" gnome \ No newline at end of file diff --git a/configs/releng/airootfs/usr/local/bin/fws-desktop-init-hyprland b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-hyprland new file mode 100644 index 0000000..8370387 --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-hyprland @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +. /usr/local/bin/fws-desktop-init-common + +first_user="$(fws_first_user)" + +fws_install_packages hyprland xdg-desktop-portal-hyprland xdg-desktop-portal-gtk waybar wofi kitty swaybg swayidle swaylock xorg-xwayland wl-clipboard grim slurp qt5-wayland qt6-wayland sddm +fws_disable_services lightdm.service gdm.service +fws_enable_services sddm.service +fws_write_sddm_config "$first_user" hyprland +fws_write_dmrc "$first_user" hyprland \ No newline at end of file diff --git a/configs/releng/airootfs/usr/local/bin/fws-desktop-init-kde b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-kde new file mode 100644 index 0000000..1a0d32e --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-kde @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +. /usr/local/bin/fws-desktop-init-common + +first_user="$(fws_first_user)" + +fws_install_packages plasma-meta konsole dolphin sddm +fws_disable_services lightdm.service gdm.service +fws_enable_services sddm.service +fws_write_sddm_config "$first_user" plasma +fws_write_dmrc "$first_user" plasma \ No newline at end of file diff --git a/configs/releng/airootfs/usr/local/bin/fws-desktop-init-xfce b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-xfce new file mode 100644 index 0000000..ba868ff --- /dev/null +++ b/configs/releng/airootfs/usr/local/bin/fws-desktop-init-xfce @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +. /usr/local/bin/fws-desktop-init-common + +first_user="$(fws_first_user)" + +fws_install_packages xfce4 xfce4-goodies lightdm lightdm-gtk-greeter +fws_disable_services sddm.service gdm.service +fws_enable_services lightdm.service +fws_write_lightdm_config "$first_user" xfce +fws_write_dmrc "$first_user" xfce \ No newline at end of file