#!/bin/sh
set -e

if [ -n ${WAYLAND_DISPLAY+x} ]; then
    # Allow Calamares to run as root via Xwayland.
    # The full Wayland version crashes at start in Qt.
    xhost si:localuser:root
fi

# enforce Adwaita-ish style when running in GNOME
style_override=""
if [ "$XDG_CURRENT_DESKTOP" = "GNOME" ]; then
    style_override="QT_STYLE_OVERRIDE=adwaita"
fi

exec pkexec env $style_override DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/calamares $@
