#!/usr/bin/sh

# Add sddm config file to the arguments 
set -- --config /etc/sway/sddm-greeter.config "$@"

# Try to use a wrapper script from sway-config-fedora
if [ -x /usr/bin/start-sway ]; then
    # shellcheck source=../sway/start-sway
    . /usr/bin/start-sway
    # unreachable
    exit 1
fi

# Set some compatibility variables in case if sway-config-fedora is not present
case $(systemd-detect-virt --vm) in
    "none"|"")
        ;;
    "kvm")
        # WLR_NO_HARDWARE_CURSORS=1 is not needed with legacy DRM interface
        export WLR_RENDERER=pixman
        export WLR_DRM_NO_ATOMIC=1
        ;;
    *)
        # https://github.com/swaywm/sway/issues/6581
        export WLR_NO_HARDWARE_CURSORS=1
        ;;
esac

exec /usr/bin/sway "$@"
