#!/usr/bin/env python3 """ Calamares job : lit le choix de bureau depuis GlobalStorage (packagechooser_desktop) et l'écrit dans /run/fws-desktop pour que shellprocess puisse appeler le bon fws-desktop-init-*. """ import libcalamares VALID_DESKTOPS = {"xfce", "kde", "gnome", "hyprland"} FALLBACK = "xfce" def pretty_name(): return "Sauvegarde du choix d'environnement de bureau" def run(): gs = libcalamares.globalstorage raw = gs.value("packagechooser_desktop") # packagechooser peut renvoyer une str ou une liste selon la version if isinstance(raw, list): choice = raw[0] if raw else FALLBACK elif isinstance(raw, str): choice = raw.strip() else: choice = FALLBACK if choice not in VALID_DESKTOPS: choice = FALLBACK try: with open("/run/fws-desktop", "w") as fh: fh.write(choice) except OSError as exc: return ( "Impossible d'écrire /run/fws-desktop", f"{exc}\nLe bureau sera xfce par défaut.", ) libcalamares.utils.debug(f"fws-desktop-choice : bureau sélectionné = {choice}") return None