feat: multi environnemnt desktop

[180][WIP]
This commit is contained in:
2026-05-27 16:02:05 +02:00
parent d5e0069889
commit a9d4b9ac91
12 changed files with 243 additions and 14 deletions
+80 -4
View File
@@ -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
@@ -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
}
@@ -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
@@ -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
@@ -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
@@ -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