Skip to content

Commit

Permalink
liveinst: Allow running as a Wayland-native application
Browse files Browse the repository at this point in the history
As long as we have the path to the Wayland socket, we can run
Anaconda as a Wayland-native application.
  • Loading branch information
Conan-Kudo committed Oct 18, 2024
1 parent 7b21249 commit b7b5800
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions data/liveinst/liveinst
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@

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
unset XAUTHORITY
if [ -z "$WAYLAND_DISPLAY" ]; then
xhost +si:localuser:root
unset XAUTHORITY
fi
pkexec "$0" "$@"
fi

Expand All @@ -33,6 +46,16 @@ if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${PKEXEC_UID}/bus
fi

# pkexec clears WAYLAND_DISPLAY from environment
if [ -z "$WAYLAND_DISPLAY" ] && [ -e "$WAYLAND_DISPLAY_SOCKET" ]; then
export WAYLAND_DISPLAY=$(cat "${WAYLAND_DISPLAY_SOCKET}")

Check warning

Code scanning / shellcheck

SC2155 Warning

Declare and assign separately to avoid masking return values.
fi

# use the correct home and config directories for system settings
PKEXEC_USER=$(id -un ${PKEXEC_UID})
export HOME=$(bash -c "cd ~${PKEXEC_USER} && pwd")

Check warning

Code scanning / shellcheck

SC2155 Warning

Declare and assign separately to avoid masking return values.
export XDG_CONFIG_HOME="${HOME}/.config"

# 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.
Expand Down Expand Up @@ -170,8 +193,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 "$@"
Expand Down

0 comments on commit b7b5800

Please sign in to comment.