Files
debianito-post-install/docs/desktops_display.md
T
stornic56 149fb56e8c Desktop environment support & QA expansion
- `.github/workflows/ci.yml` added as a new workflow: job `lint-and-test` on `runs-on: ubuntu-latest` with `container: debian:trixie`, checking out via `actions/checkout@v4`, installing `bats` and `shellcheck`, running `shellcheck --severity=error debianito.sh modules/**/*.sh` (with `shopt -s globstar`) and `bats tests/`.

- `debianito.sh` CLI parser: `AUTO_YES=0`, `ALLOW_DESTRUCTIVE=0` declared after `MODULES_DIR` and before `_boot_mark`; `_usage()` prints `Usage: debianito.sh [OPTIONS]` with `--yes`, `--allow-destructive` and `--help`; the `while [ $# -gt 0 ]` / `case` loop consumes `--yes` and `--allow-destructive`, prints `Unknown option: $1 (run with --help for usage)` to stderr and `exit 2` for unknown flags, and `--help|-h` runs `_usage` then `exit 0`.

- `modules/utils.sh`: new global `_SELECTION_CONFIRMED=0` and `_confirm_install_list()` (utils.sh:756-785), which renders items capped at 15 with `... and N more`, computes `height` capped at 24, calls `_confirm "$title" "$list" "$height" 65`, arms `_SELECTION_CONFIRMED=${#items[@]}` on yes, and returns 1 for an empty list or on decline. `_install_pkg()` (utils.sh:789-804) decrements the countdown instead of prompting, and only prompts via `elif ! _confirm "Install: ${pkg}" "Install ${pkg}\nVersion: ${ver}?"; then return 0`.

- Bulk retrofit in `modules/extras/**/*.sh` (18 sites): `_confirm_install_list "Título" "${array[@]}" || return` placed right after the `whiptail` selection is parsed, the install loop left intact, and `_SELECTION_CONFIRMED=0` after the loop. Files: office/office.sh:101, system/software_centers.sh:29, system/system.sh:133, communication/communication.sh:68, design/design.sh:42, download/download.sh:48+55, terminals/terminals.sh:31, security/security.sh:30, players/players.sh:20, themes/fonts/fonts.sh:32, dev/dev.sh:44, programming/programming.sh:57, themes/desktop-themes/desktop-themes.sh:30, fetch/fetch.sh:41, themes/icons/icons.sh:47, themes/cursors/cursors.sh:28, internet/internet.sh:197, java.

- `modules/bullseye/extras.sh` (13 sites) plus `modules/bullseye/legacy.sh` (1 site, `install_gaming_bullseye`, guarded with `if [ ${#_install_pkgs[@]} -gt 0 ]` so a i386-only selection does not blank the summary) plus `modules/desktop_display.sh` (1 site, XFCE Custom — a no-loop `_run_cmd` batch with the reset immediately after it). Special cases: download.sh and bullseye/download each have two checklists merged into one combined summary; legacy.sh gaming skips the reset when the list is empty; XFCE Custom resets before `_xfce_polkit_rules` so the counter cannot leak.

- `modules/desktops/desktop_gnome.sh` (new): `gnome_menu()` runs a `_radiolist` with "1" "GNOME (Full Desktop)", "2" "GNOME Core (Minimal Install)", "3" "Back", then `_install_gnome_full()` and `_install_gnome_core()`. Each arms `_confirm_install_list "GNOME Full Desktop" gnome gdm3 || return` (core: `gnome-core gdm3`), keeps an already-configured display manager via `_existing_display_manager` by setting `target_dm="$keep_dm"`, writes the preseed `echo "${target_dm} shared/default-x-display-manager select ${target_dm}" | sudo debconf-set-selections`, installs `sudo apt install -y gnome gdm3` / `gnome-core gdm3`, enables `gdm3` only when `target_dm = "gdm3"`, resets `_SELECTION_CONFIRMED=0` and calls `_offer_pipewire_after_desktop`.

- `modules/desktops/desktop_kde.sh` (new): `kde_menu()` runs a `_radiolist` with "1" "KDE Plasma (Full Desktop)", "2" "KDE Plasma Desktop (Minimal)", "3" "Back"; `_install_kde_full()` and `_install_kde_minimal()` arm `_confirm_install_list "KDE Plasma Full" kde-standard sddm || return` (minimal: `kde-plasma-desktop sddm`), preseed `sddm shared/default-x-display-manager select sddm`, install `sudo apt install -y kde-standard sddm` / `kde-plasma-desktop sddm`, enable `sddm` only when it is the target DM, reset the counter and offer PipeWire.

- `modules/desktop_display.sh` `desktop_environment_menu()`: `env_items+=("3" "GNOME")`, `env_items+=("4" "KDE Plasma")`, `env_items+=("5" "Back")`; the case adds `3)` loading `gnome` via `_load_module gnome || continue` and calling `gnome_menu`, and `4)` loading `kde` via `_load_module kde || continue` and calling `kde_menu`; the dead TODO comment was removed.

- PipeWire retrofit in `modules/desktop_display.sh` (6 sites): `_install_lxde_full`, `_install_lxde_core`, `_install_xfce_full`, `_install_xfce_minimal`, `_install_xfce_wayland` and `_install_xfce_custom` each call `_offer_pipewire_after_desktop` after their install block.

- `_offer_pipewire_after_desktop()` and `_existing_display_manager()` added at the end of `modules/desktop_display.sh`: `_offer_pipewire_after_desktop` checks `pipewire-audio` (`pipewire` when `DEBIAN_VERSION = 11`), returns 0 via `is_installed`, otherwise `_confirm "PipeWire Audio" "No PipeWire audio server is installed.\n\nInstall the PipeWire audio stack (recommended)?"` calls `_install_pipewire_standard` and returns 0. `_existing_display_manager` reads `${DM_FILE:-/etc/X11/default-display-manager}`, reads the basename as the DM, and otherwise scans `gdm3 lightdm sddm greetd gdm` with `systemctl is-enabled`, printing nothing when none is found.

- `_ensure_apt_updated` added before the GNOME/KDE `apt install` transactions (4 sites, deduplicated per session); `gnome gdm3` and `kde-standard sddm` are installed alongside even when another display manager is kept as the default.

- Extraction to `modules/desktops/`: `desktop_lxde.sh` (38 lines) and `desktop_xfce.sh` (119 lines) created with the `lxde_menu` / `_install_lxde_full` / `_install_lxde_core` and `xfce_menu` / `_install_xfce_full` / `_install_xfce_minimal` / `_install_xfce_wayland` / `_install_xfce_custom` / `_xfce_polkit_rules` blocks moved verbatim; both carry `# License GPL v3` in their headers.

- `modules/desktop_display.sh` reduced from 542 to 394 lines (−154): lines 55-208 removed, the dispatch (desktop_display.sh:39-46) replaced with `_load_module xfce || continue` / `lxde_menu`, and the file left with `manage_desktop_display`, `desktop_environment_menu`, `display_manager_menu`, `lightdm_config_menu`, `configure_greetd`, `configure_gdm3`, `configure_sddm`, the two shared helpers.

- `modules/utils.sh` `_load_module` map: `xfce)` → `${MODULES_DIR}/desktops/desktop_xfce.sh`, `lxde)` → `${MODULES_DIR}/desktops/desktop_lxde.sh`, `gnome)` → `${MODULES_DIR}/desktops/desktop_gnome.sh`, `kde)` → `${MODULES_DIR}/desktops/desktop_kde.sh`; deps for `xfce`, `lxde`, `gnome` and `kde` are `(desktop_display audio)` and `desktop_display` is `(repos audio)`.

- `modules/desktops/desktop_xfce.sh` `_xfce_polkit_rules()` writes `/etc/polkit-1/rules.d/85-suspend.rules` and `89-backlight.rules` via `sudo tee`, adds the `backlight` group with `groupadd --system` fallback, adds the real login user from `/etc/passwd` to `backlight` and restarts `polkit.service`.

- ES→EN user-facing strings: 14 strings across 4 files — `desktop_display.sh` `lxdе_menu` ("LXDE (Full Desktop)", "LXDE Core (Minimal Install)"), `gpu/nvidia.sh` Kepler legacy-driver notice ("Kepler GPU detected (GKxxx)… Install the legacy driver for Kepler?"), `bullseye/legacy.sh` ("Install NVIDIA driver?", "Skipping NVIDIA driver.", "Installing NVIDIA driver ${gpu_gen}...") and `bullseye/extras.sh` ("firmware-linux-nonfree provides drivers for… Install?").

- ES→EN internal comments: ~35 comments across 9 files — section headers in `_install_nvidia_standard`, `gpu/_helpers.sh` (lines 5, 113), `gpu/nvidia.sh` (lines 8-12, 19-22, 68-70, 167-172, 196, 239-253, 262-263, 275, 291, 336-338, 376), `gpu.sh` (lines 15-17), `bullseye/repos.sh` (line 2), `firmware.sh` (line 235, "--- Load verification ---"), `utils.sh` (lines 129, 132, 153 — timezone Paso 1/2/4) and `utils.sh:546,548`.

- set -e abort fix: `debianito.sh:149` now reads `_system_preferences_menu || true`, consistent with the other dispatch chains (14 of the 15 chains already had the guard); a declined pre-apply summary now leaves the TUI alive instead of terminating the script.

- `docs/desktops_display.md`: 4 hunks — intro now lists GNOME/GNOME Core/KDE Plasma/KDE Plasma Desktop/XFCE/XFCE Wayland/XFCE Custom/LXDE, a new "Modular layout" paragraph describing `modules/desktops/` and lazy loading, Block 1 rewritten into four environments, five new bullets (pre-apply summary, existing-DM preservation, PipeWire offer, stale-lists guard) and a Desktop Environment Packages table.

- `docs/quickstart.md` line 284: Desktop Environment entry expanded to pick from XFCE (full / minimal / Wayland `labwc` on Trixie / custom checklist), LXDE (full / core), GNOME (full / core) or KDE Plasma (full / minimal).

- `_existing_display_manager` now takes the config path via `local dm_file="${DM_FILE:-/etc/X11/default-display-manager}"` so the offline test suite never reads the real system file.

- `tests/test_helper.bash`: added `_mock_systemctl()` for `is-enabled` (units in `MOCK_SYSTEMCTL_ENABLED` report `enabled`, everything else `disabled`), `MOCK_SYSTEMCTL_ENABLED=""`, `WHIPTAIL_CALLS`/`MOCK_WHIPTAIL_OUTPUT`/`MOCK_WHIPTAIL_RC`, `MOCK_DPKG_INSTALLED` and the `systemctl` entry in the mock list and in `mock_reset()`.

- `tests/desktops.bats` created with 16 tests: `_existing_display_manager` (file read, file-preferred over an enabled unit, enabled-unit fallback, candidate order, missing file, nothing configured), `_offer_pipewire_after_desktop` (5 tests: skip-installed, accept-installs, decline-returns-0, Bullseye package name, wrong package name on 11), `_load_module` (4 tests for xfce/lxde/gnome/kde) and an unknown-module case; 17→33 tests total.

- `.github/workflows/ci.yml` shellcheck severity raised from `--severity=error` to `--severity=warning`.

- `debianito.sh`: `RED`, `GREEN`, `YELLOW`, `CYAN` and `NC` plus `AUTO_YES`, `ALLOW_DESTRUCTIVE` and `DEBIAN_CODENAME` are now `export`ed as cross-file globals.

- `modules/utils.sh`: `HAS_NVIDIA`, `DESKTOP_ENV`, `AUDIO_SERVER`, `DEBIAN_VERSION` and the other cross-file globals are `export`ed.

- `modules/extras/system/software_centers.sh` gained a `#!/usr/bin/env bash` shebang.

- `shellcheck` triage (v0.11.0, baseline `--severity=warning` 25 findings → 0): removed two dead-code lines (`headless` in `extras/dev/dev.sh`, orphan `dev_id` in `firmware.sh`); `SC2206` in `extras/dev/essential.sh` fixed by expanding `$comp_pkgs` to `"${comp_pkgs[@]}"`; `SC2010`/`SC2046` (3 sites) replaced `ls … | grep` with `compgen -G "…"`; `SC2155` (2 sites, `gpu.sh` and `rescue.sh`) split command substitutions into separate lines; `SC2166` in `repos.sh` replaced `-o` with `{ … || … }`; `SC2221`/`SC2222` (2 sites, `sysinfo.sh` and `utils.sh`) collapsed the `wl*|wlp*|wlo*|wlan*` alternation to `wl*`; `SC1090` in `extras.sh` gained a justification comment on the disable directive.

- Final verification: `bash -n` on all 15 modified `.sh` files and `set -euo pipefail` at `debianito.sh:3` both intact; `bats tests/` reports 33 ok / 0 failed; invariants `offers 11`, `confirm_install_list 39` and `_SELECTION_CONFIRMED=0 40` hold.
2026-10-05 23:17:38 -05:00

9.9 KiB

Option 13: Desktop & Display

1. What does this component do?

This component manages both desktop environments and display managers. Desktop Environment installs GNOME, KDE Plasma, XFCE, or LXDE; Display Manager handles LightDM, GDM3, SDDM, and greetd (login screens). It handles autologin setup, user list visibility toggles, and a specific Wayland override for NVIDIA GPUs. Desktop Environment management supports XFCE (full / minimal / Wayland labwc on Trixie / custom), LXDE (full / core), GNOME (full / core) and KDE Plasma (full / minimal), with polkit rules for suspend/backlight where applicable.

Modular layout: the menu, the shared helpers (_existing_display_manager, _offer_pipewire_after_desktop) and the display-manager configuration routines live in modules/desktop_display.sh; every desktop installer lives in its own module under modules/desktops/ (desktop_xfce.sh, desktop_lxde.sh, desktop_gnome.sh, desktop_kde.sh), lazily loaded on demand via _load_module.

2. Logical Flow of Execution

The execution logic is divided into five functional blocks:

Block 1 — Desktop Environment Selection & Installation

  • The main menu (manage_desktop_display in desktop_display.sh) offers two primary options: 1 Desktop Environment and 2 Display Manager (plus 3 Back to main menu).
  • Desktop Environment opens desktop_environment_menu with four environments:
    1. XFCE — full / minimal / Wayland (labwc, Debian 13 only) / custom package checklist.
    2. LXDE — full / core.
    3. GNOME — full (gnome) / core (gnome-core), with GDM3.
    4. KDE Plasma — full (kde-standard) / minimal (kde-plasma-desktop), with SDDM.
  • Each environment lives in its own module under modules/desktops/ and is lazy-loaded from the menu dispatch with _load_module xfce|lxde|gnome|kde (dependencies: desktop_display + audio).
  • Display Manager opens display_manager_menu — LightDM, GDM3, SDDM, and greetd (12/13 only).
  • Available Managers:
    • LightDM (available on all Debian versions).
    • GDM3 (available on all Debian versions).
    • SDDM (available on all Debian versions).
    • greetd (available only on Debian 12 and 13).
  • Each selected manager opens its own dedicated configuration submenu.

Block 2 — LightDM Configuration

  • A checklist menu presents three options:
    1. Install LightDM + GTK Greeter (auto-selects the display manager via debconf-set-selections).
    2. Enable user list at login screen (writes greeter-hide-users=false to a configuration file in .conf.d).
    3. Enable autologin for current user (uncomments autologin-user and sets timeout to 0 in the main config).
  • Idempotency: The script checks if lightdm and lightdm-gtk-greeter-settings are already installed before attempting installation, skipping redundant steps.

Block 3 — GDM3 Configuration

  • A checklist menu presents up to four options:
    1. Install/Reinstall gdm3 (auto-selects via debconf).
    2. Toggle user list visibility (toggles disable-user-list in greeter.dconf-defaults).
    3. Configure autologin (prompts for a username via whiptail inputbox to set in daemon.conf).
    4. Force Enable Wayland on NVIDIA (Bookworm/Trixie + NVIDIA only).
      • Mechanism: Creates or removes a symlink: /etc/udev/rules.d/61-gdm.rules → /dev/null.
      • Purpose: This disables the udev rule that blocks GDM from using Wayland on NVIDIA GPUs.
      • Risk Warning: Displays a warning that this may break graphics or cause instability.
      • Toggle Behavior: If the symlink exists, removing it reverts to default behavior; if not present, creating it enables the override.

Block 4 — SDDM Configuration

  • A submenu offers two options:
    1. Install SDDM (auto-selects via debconf).
    2. Enable Autologin:
      • Session Detection: Auto-detects the installed session by checking .desktop files in priority order: plasmawayland → lxqt-wayland → plasma → lxqt.
      • Configuration: Writes autologin settings to /etc/sddm.conf.d/autologin.conf.
      • Fallback: If no session is found, it enables autologin but warns that SDDM will use the default session.

Block 5 — greetd Configuration

  • greetd is a minimal, modern display manager designed for Wayland environments.
  • Submenu options vary by Debian version:
    • All Versions: Install base greetd, Install greetd + tuigreet (recommended TUI greeter).
    • Debian 13 only: Additional options to install gtk-greet, nwg-hello, or wlgreet.
  • Backports Handling: On Bookworm, tuigreet is installed from backports if not enabled.
  • Important Warning: greetd is installed but NOT configured by the script. The user must manually create /etc/greetd/config.toml to be able to log in. The script displays a warning with references to man pages for configuration details.

3. Smart Automations

The component utilizes several intelligent automation features:

  • debconf-set-selections: Pre-selects the display manager as default before apt install, preventing the interactive "Configuring shared/default-x-display-manager" dialog that would otherwise pause the script execution.
  • Session Auto-Detection (SDDM): Checks .desktop files in priority order (Wayland first, then X11) to set the correct session type for autologin configuration.
  • Wayland Toggle: Creates or removes a udev rule symlink to /dev/null. This is a known workaround that disables the GDM rule blocking NVIDIA Wayland support.
  • greetd Backports: On Bookworm, tuigreet is installed from backports (newer version) if not already enabled in the system.
  • Manual Config Warning: The script explicitly informs users that greetd requires manual configuration and points to man pages for further details.
  • User Detection: Uses SUDO_USER (the real user who ran sudo) instead of $USER (which is root during script execution). This ensures the correct user is set for automatic login across all display managers.
  • Pre-apply Summary: every desktop installer shows a confirmation list of the packages (_confirm_install_list) before any debconf or apt transaction starts; declining aborts safely.
  • Existing DM Preservation: the GNOME and KDE installers detect the current default display manager (_existing_display_manager reads /etc/X11/default-display-manager, falling back to an enabled DM systemd unit), preseed that manager instead of the new one, and skip systemctl enable so an already-configured login screen is never overwritten.
  • PipeWire Offer: after any desktop install (XFCE, LXDE, GNOME, KDE), _offer_pipewire_after_desktop checks for pipewire-audio (pipewire on Bullseye) and, when missing, asks once before running _install_pipewire_standard. Declining is a choice, not an error: the helper always returns 0.
  • Stale-lists Guard: _ensure_apt_updated runs before the GNOME/KDE apt install transactions, refreshing the package lists at most once per session.

4. Packages and Resources Managed

Display Manager Packages:

DM Packages Debian Versions
LightDM lightdm, lightdm-gtk-greeter, lightdm-gtk-greeter-settings All
GDM3 gdm3 All
SDDM sddm All
greetd (base) greetd 12, 13
greetd + tuigreet greetd, tuigreet 12 (backports), 13
greetd + gtk-greet greetd, gtk-greet 13 only
greetd + nwg-hello greetd, nwg-hello 13 only
greetd + wlgreet greetd, wlgreet 13 only

Desktop Environment Packages:

Environment Variant Packages Display Manager
XFCE Full xfce4, xfce4-goodies, xfce4-power-manager not managed by the installer
XFCE Minimal xfce4 not managed by the installer
XFCE Wayland (13 only) xfce4, labwc not managed by the installer
XFCE Custom user-selected checklist not managed by the installer
LXDE Full / Core lxde / lxde-core lightdm (always)
GNOME Full / Core gnome / gnome-core gdm3 (installed; existing DM kept as default)
KDE Plasma Full / Minimal kde-standard / kde-plasma-desktop sddm (installed; existing DM kept as default)

Configuration Files Modified:

DM File Path Configuration Purpose
LightDM /etc/lightdm/lightdm.conf.d/50-debianito-userlist.conf User list visibility toggle
LightDM /etc/lightdm/lightdm.conf Autologin user + timeout settings
GDM3 /etc/gdm3/greeter.dconf-defaults User list toggle (disable-user-list)
GDM3 /etc/gdm3/daemon.conf Autologin user and enable flag
GDM3 /etc/udev/rules.d/61-gdm.rules Wayland override (symlink to /dev/null)
SDDM /etc/sddm.conf.d/autologin.conf Autologin user + session type

Session Detection Priority (SDDM Autologin):

Priority Session File Session Type
1 /usr/share/wayland-sessions/plasmawayland.desktop KDE Wayland
2 /usr/share/wayland-sessions/lxqt-wayland.desktop LXQt Wayland
3 /usr/share/xsessions/plasma.desktop KDE X11
4 /usr/share/xsessions/lxqt.desktop LXQt X11

⚠️ Warning: Wayland on NVIDIA: The "Force Enable Wayland on NVIDIA" option creates a symlink that disables the GDM udev rule. This is a known workaround but MAY cause graphics instability or breakage. To revert, remove /etc/udev/rules.d/61-gdm.rules.

⚠️ Warning: greetd: Unlike other display managers, greetd is installed but NOT configured by this script. You MUST manually create /etc/greetd/config.toml before you can log in. See man greetd and man 5 greetd-sessions for configuration details.

⚠️ Warning: Autologin: All autologin configurations use SUDO_USER (the user who ran sudo) instead of $USER (which is root during script execution). This ensures the correct user is set for automatic login.

💡 Technical Note: debconf-set-selections pre-selects the display manager before apt install, preventing the interactive "Configuring shared/default-x-display-manager" dialog that would otherwise pause the script.