From 54a7098b7f70418a8a60e9e762e25f933aad07fe Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Mon, 21 Oct 2024 07:35:32 -0400 Subject: [PATCH] liveinst: Allow running as a Wayland-native application As long as we have the path to the Wayland socket, we can run Anaconda as a Wayland-native application. --- data/liveinst/liveinst | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/data/liveinst/liveinst b/data/liveinst/liveinst index 4ea37b44fb4..f956aee9fea 100755 --- a/data/liveinst/liveinst +++ b/data/liveinst/liveinst @@ -20,10 +20,23 @@ BACKEND_READY_FLAG=/run/anaconda/backend_ready +WAYLAND_DISPLAY_SOCKET=/tmp/anaconda-wldisplay + +# Detect and save the wayland socket before re-exec +if [ -n "$WAYLAND_DISPLAY" ]; then + if [ -e "$WAYLAND_DISPLAY_SOCKET" ]; then + rm -f "${WAYLAND_DISPLAY_SOCKET}" + fi + touch "${WAYLAND_DISPLAY_SOCKET}" + echo "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}" > ${WAYLAND_DISPLAY_SOCKET} +fi + # The command needs to be run with root privileges, so if it was started # unprivileged, restart running as root. if [ "$(id -u)" -ne 0 ]; then - xhost +si:localuser:root + if [ -z "$WAYLAND_DISPLAY" ]; then + xhost +si:localuser:root + fi pkexec "$0" "$@" exit $? fi @@ -38,6 +51,19 @@ if [ -n "${PKEXEC_UID}" ]; then done fi +# pkexec clears WAYLAND_DISPLAY from environment +if [ -z "$WAYLAND_DISPLAY" ] && [ -e "$WAYLAND_DISPLAY_SOCKET" ]; then + WAYLAND_DISPLAY=$(cat "${WAYLAND_DISPLAY_SOCKET}") + export WAYLAND_DISPLAY +fi + +# use the correct home and config directories for system settings +PKEXEC_USER=$(id -un "${PKEXEC_UID}") +HOME=$(bash -c "cd ~${PKEXEC_USER} && pwd") +export HOME +XDG_CONFIG_HOME="${HOME}/.config" +export XDG_CONFIG_HOME + # Allow running another command in the place of anaconda, but in this same # environment. This allows storage testing to make use of all the module # loading and lvm control in this file, too. @@ -175,8 +201,10 @@ start_anaconda() { $ANACONDA "$@" } -# Force the X11 backend since sudo and wayland do not mix -export GDK_BACKEND=x11 +# If no wayland socket is set, force x11 so that it loads correctly +if [ -z "$WAYLAND_DISPLAY" ]; then + export GDK_BACKEND=x11 +fi if [ -x /usr/bin/udisks ]; then /usr/bin/udisks --inhibit -- start_anaconda "$@"