diff --git a/biglinux-livecd/usr/bin/startbiglive b/biglinux-livecd/usr/bin/startbiglive index 47613c1c..e511d228 100755 --- a/biglinux-livecd/usr/bin/startbiglive +++ b/biglinux-livecd/usr/bin/startbiglive @@ -38,6 +38,39 @@ _split_xkb_layout() { fi } +_fcitx5_keyboard_input_method() { + if [[ -n $2 ]]; then + printf 'keyboard-%s-%s\n' "$1" "$2" + else + printf 'keyboard-%s\n' "$1" + fi +} + +_configure_fcitx5_keyboard_profile() { + local layout=$1 variant=$2 input_method profile_directory + input_method=$(_fcitx5_keyboard_input_method "$layout" "$variant") + profile_directory=$HOME/.config/fcitx5 + mkdir -p -- "$profile_directory" + cat >"$profile_directory/profile" </dev/null || true fi +_reset_gnome_portals() { + # The wizard can activate the portal before the GNOME environment exists. + # Reset it so the desktop session selects the GNOME Settings backend. + dbus-update-activation-environment --systemd \ + DESKTOP_SESSION XDG_SESSION_DESKTOP GDMSESSION XDG_CURRENT_DESKTOP \ + 2>/dev/null || true + systemctl --user import-environment \ + DESKTOP_SESSION XDG_SESSION_DESKTOP GDMSESSION XDG_CURRENT_DESKTOP \ + 2>/dev/null || true + systemctl --user stop \ + xdg-desktop-portal.service \ + xdg-desktop-portal-gtk.service \ + xdg-desktop-portal-gnome.service \ + 2>/dev/null || true +} + # 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. @@ -675,6 +727,7 @@ elif [[ "$display_manager" == "gdm" ]]; then # GNOME: Clean up and start gnome-session rm -f "$HOME/Empty Bash" "$HOME/Empty Desktop File.desktop" "$HOME/Empty File" xdg-user-dirs-update + _reset_gnome_portals exec startgnome-community elif [[ -e /usr/share/wayland-sessions/hyprland.desktop ]]; then diff --git a/tests/test_livecd_keyboard.py b/tests/test_livecd_keyboard.py index 125bd6a6..6ebabda7 100644 --- a/tests/test_livecd_keyboard.py +++ b/tests/test_livecd_keyboard.py @@ -90,6 +90,7 @@ def test_startbiglive_applies_saved_keyboard_layout(tmp_path: Path) -> None: result = run_bash( f""" _log() {{ :; }} +display_manager=sddm live_state_path() {{ printf '%s\\n' "$STATE_FILE"; }} setxkbmap() {{ printf 'setxkbmap:%s\\n' "$*" >>"$COMMAND_LOG"; }} sudo() {{ printf 'sudo:%s\\n' "$*" >>"$COMMAND_LOG"; }} @@ -105,6 +106,7 @@ def test_startbiglive_applies_saved_keyboard_layout(tmp_path: Path) -> None: assert result.returncode == 0, result.stderr kxkbrc = (home / ".config/kxkbrc").read_text(encoding="utf-8") + fcitx_profile = (home / ".config/fcitx5/profile").read_text(encoding="utf-8") commands = command_log.read_text(encoding="utf-8") assert "setxkbmap:us -variant intl\n" in commands assert ( @@ -113,3 +115,8 @@ def test_startbiglive_applies_saved_keyboard_layout(tmp_path: Path) -> None: ) assert "LayoutList=us\n" in kxkbrc assert "VariantList=intl\n" in kxkbrc + assert 'Name="Live Keyboard"\n' in fcitx_profile + assert "Default Layout=us\n" in fcitx_profile + assert "DefaultIM=keyboard-us-intl\n" in fcitx_profile + assert "Name=keyboard-us-intl\n" in fcitx_profile + assert '0="Live Keyboard"\n' in fcitx_profile diff --git a/tests/test_livecd_security.py b/tests/test_livecd_security.py index a766036e..76744b0f 100644 --- a/tests/test_livecd_security.py +++ b/tests/test_livecd_security.py @@ -285,6 +285,47 @@ def test_startbiglive_defers_noncritical_work_until_after_wizard() -> None: assert wizard_launch < theme_sync +def test_startbiglive_resets_early_portals_before_gnome(tmp_path: Path) -> None: + source = STARTBIGLIVE.read_text(encoding="utf-8") + function_start = source.index("_reset_gnome_portals() {") + function_end = source.index("\n}\n", function_start) + 3 + function = source[function_start:function_end] + command_log = tmp_path / "commands" + result = run_bash( + f""" +dbus-update-activation-environment() {{ + printf 'dbus:%s\\n' "$*" >>"$COMMAND_LOG" +}} +systemctl() {{ + printf 'systemctl:%s\\n' "$*" >>"$COMMAND_LOG" +}} +{function} +_reset_gnome_portals +""", + environment={"COMMAND_LOG": str(command_log)}, + ) + assert result.returncode == 0, result.stderr + assert command_log.read_text(encoding="utf-8").splitlines() == [ + ( + "dbus:--systemd DESKTOP_SESSION XDG_SESSION_DESKTOP " + "GDMSESSION XDG_CURRENT_DESKTOP" + ), + ( + "systemctl:--user import-environment DESKTOP_SESSION " + "XDG_SESSION_DESKTOP GDMSESSION XDG_CURRENT_DESKTOP" + ), + ( + "systemctl:--user stop xdg-desktop-portal.service " + "xdg-desktop-portal-gtk.service " + "xdg-desktop-portal-gnome.service" + ), + ] + gnome_branch = source.index('elif [[ "$display_manager" == "gdm" ]]') + reset = source.index("_reset_gnome_portals", gnome_branch) + session = source.index("exec startgnome-community", gnome_branch) + assert reset < session + + def test_wizard_defers_noninitial_pages_and_accessibility_backends() -> None: app_window = ( PACKAGE / "usr/share/biglinux/livecd/ui/app_window.py"