From 0193f198ad7406ade3e4ef4b965014075be4a4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tales=20A=2E=20Mendon=C3=A7a?= Date: Fri, 24 Jul 2026 18:08:29 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20(livecd):=20hand=20off=20?= =?UTF-8?q?Plasma=20wizard=20theme=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Publish the live wizard theme and desktop selections from /tmp to /etc/big-default-config before starting the real Plasma session. Also clear Plasma markers created by the temporary wizard compositor so startkde-biglinux reapplies the selected theme and layout in the final desktop session instead of treating the temporary state as already applied. --- biglinux-livecd/usr/bin/startbiglive | 25 ++++++++ .../usr/lib/biglinux-livecd/live-state | 27 +++++++- tests/test_livecd_security.py | 61 +++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/biglinux-livecd/usr/bin/startbiglive b/biglinux-livecd/usr/bin/startbiglive index e511d228..29979a22 100755 --- a/biglinux-livecd/usr/bin/startbiglive +++ b/biglinux-livecd/usr/bin/startbiglive @@ -398,6 +398,7 @@ _apply_default_config() { _log "Applying default configuration (wizard was skipped)" write_live_state language en_US write_live_state desktop-theme breeze + write_live_state desktop 'startkde-biglinux classic' } #------------------------------------------------------------------------------- @@ -694,6 +695,29 @@ _reset_gnome_portals() { 2>/dev/null || true } +_plasma_live_layout_name() { + local desktop_state desktop_state_file layout + desktop_state_file=$(live_state_path desktop) || return 1 + [[ -f $desktop_state_file && ! -L $desktop_state_file ]] || return 1 + desktop_state=$(<"$desktop_state_file") + layout=$(cut -f2 -d" " <<<"$desktop_state") + [[ $layout =~ ^[A-Za-z0-9_.+-]+$ ]] || return 1 + printf '%s\n' "$layout" +} + +_prepare_plasma_live_defaults() { + local layout + if ! install_live_state_defaults; then + _log "WARNING - Could not install Plasma live defaults" + return 0 + fi + [[ -n ${HOME:-} && $HOME != / ]] || return 0 + rm -f -- "$HOME/.big_desktop_theme" "$HOME/.kdebiglinux/lastlogin" "$HOME/.kdebiglinux/lastused" + if layout=$(_plasma_live_layout_name); then + rm -rf -- "$HOME/.kdebiglinux/$layout" + fi +} + # libadwaita apps use their own color-scheme setting and can ignore GTK INI files # in non-GNOME sessions. GNOME reads color-scheme from dconf directly, and the # forced override would fight the wizard's choice there, so skip it on gdm. @@ -736,6 +760,7 @@ elif [[ -e /usr/share/wayland-sessions/hyprland.desktop ]]; then elif [[ "$display_manager" == "sddm" || "$display_manager" == "lxdm" ]]; then # KDE Plasma + _prepare_plasma_live_defaults if [[ "$session_type" == "x11" ]]; then exec startkde-biglinux else diff --git a/biglinux-livecd/usr/lib/biglinux-livecd/live-state b/biglinux-livecd/usr/lib/biglinux-livecd/live-state index dbaa5966..7968e433 100755 --- a/biglinux-livecd/usr/lib/biglinux-livecd/live-state +++ b/biglinux-livecd/usr/lib/biglinux-livecd/live-state @@ -1,6 +1,9 @@ #!/usr/bin/env bash live_state_directory=/tmp +live_state_default_config_directory=/etc/big-default-config +live_state_legacy_theme_path=/etc/default-theme-biglinux +live_state_legacy_desktop_path=/etc/big_desktop_changed live_state_path() { case "$1" in @@ -53,7 +56,27 @@ initialize_default_live_state() { } install_live_state_defaults() { + local desktop_state theme_state require_live_state_directory || return 1 - sudo install -m 0644 -- "$(live_state_path desktop-theme)" /etc/default-theme-biglinux - sudo install -m 0644 -- "$(live_state_path desktop)" /etc/big_desktop_changed + theme_state=$(live_state_path desktop-theme) || return 1 + desktop_state=$(live_state_path desktop) || return 1 + [[ -f $theme_state && ! -L $theme_state ]] || return 1 + [[ -f $desktop_state && ! -L $desktop_state ]] || return 1 + + sudo -n install -d -m 0755 -- "$live_state_default_config_directory" + sudo -n install -m 0644 -- "$theme_state" "$live_state_default_config_directory/theme" + sudo -n install -m 0644 -- "$desktop_state" "$live_state_default_config_directory/desktop" + sudo -n install -m 0644 -- "$theme_state" "$live_state_legacy_theme_path" + sudo -n install -m 0644 -- "$desktop_state" "$live_state_legacy_desktop_path" + + if [[ -f $(live_state_path enable-jamesdsp) && ! -L $(live_state_path enable-jamesdsp) ]]; then + sudo -n install -m 0644 -- "$(live_state_path enable-jamesdsp)" "$live_state_default_config_directory/jamesdsp" + else + sudo -n rm -f -- "$live_state_default_config_directory/jamesdsp" + fi + if [[ -f $(live_state_path improve-display) && ! -L $(live_state_path improve-display) ]]; then + sudo -n install -m 0644 -- "$(live_state_path improve-display)" "$live_state_default_config_directory/display-profile" + else + sudo -n rm -f -- "$live_state_default_config_directory/display-profile" + fi } diff --git a/tests/test_livecd_security.py b/tests/test_livecd_security.py index 76744b0f..2c081812 100644 --- a/tests/test_livecd_security.py +++ b/tests/test_livecd_security.py @@ -326,6 +326,67 @@ def test_startbiglive_resets_early_portals_before_gnome(tmp_path: Path) -> None: assert reset < session +def test_live_state_defaults_publish_plasma_contract(tmp_path: Path) -> None: + state_directory = tmp_path / "state" + default_config = tmp_path / "etc/big-default-config" + legacy_theme = tmp_path / "etc/default-theme-biglinux" + legacy_desktop = tmp_path / "etc/big_desktop_changed" + state_directory.mkdir() + default_config.mkdir(parents=True) + (default_config / "jamesdsp").write_text("stale", encoding="utf-8") + (default_config / "display-profile").write_text("stale", encoding="utf-8") + result = run_bash( + """ +source "$LIVE_STATE" +sudo() { + if [[ ${1:-} == -n ]]; then + shift + fi + "$@" +} +live_state_directory=$STATE_DIRECTORY +live_state_default_config_directory=$DEFAULT_CONFIG +live_state_legacy_theme_path=$LEGACY_THEME +live_state_legacy_desktop_path=$LEGACY_DESKTOP +write_live_state desktop-theme biglinux +write_live_state desktop classic +install_live_state_defaults +""", + environment={ + "LIVE_STATE": str(LIVE_STATE), + "STATE_DIRECTORY": str(state_directory), + "DEFAULT_CONFIG": str(default_config), + "LEGACY_THEME": str(legacy_theme), + "LEGACY_DESKTOP": str(legacy_desktop), + }, + ) + assert result.returncode == 0, result.stderr + assert (default_config / "theme").read_text(encoding="utf-8") == "biglinux" + assert (default_config / "desktop").read_text(encoding="utf-8") == "classic" + assert legacy_theme.read_text(encoding="utf-8") == "biglinux" + assert legacy_desktop.read_text(encoding="utf-8") == "classic" + assert not (default_config / "jamesdsp").exists() + assert not (default_config / "display-profile").exists() + + +def test_startbiglive_prepares_plasma_defaults_before_session() -> None: + source = STARTBIGLIVE.read_text(encoding="utf-8") + function_start = source.index("_prepare_plasma_live_defaults() {") + function_end = source.index("\n}\n", function_start) + 3 + function = source[function_start:function_end] + assert "install_live_state_defaults" in function + assert 'rm -f -- "$HOME/.big_desktop_theme"' in function + assert '"$HOME/.kdebiglinux/lastlogin"' in function + assert '"$HOME/.kdebiglinux/lastused"' in function + + plasma_branch = source.index( + 'elif [[ "$display_manager" == "sddm" || "$display_manager" == "lxdm" ]]' + ) + prepare = source.index("_prepare_plasma_live_defaults", plasma_branch) + session = source.index("exec startkde-biglinux", plasma_branch) + assert prepare < session + + def test_wizard_defers_noninitial_pages_and_accessibility_backends() -> None: app_window = ( PACKAGE / "usr/share/biglinux/livecd/ui/app_window.py"