summaryrefslogtreecommitdiff
path: root/meshmc/launcher/MeshMC.in
blob: 921b6162d8e357254260537c102628357e9b032c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Project Tick
# SPDX-FileContributor: Project Tick
# SPDX-License-Identifier: GPL-3.0-or-later
# Basic start script for running the launcher with the libs packaged with it.

function printerror {
    printf "$1"
    if which zenity >/dev/null; then zenity --error --text="$1" &>/dev/null;
    elif which kdialog >/dev/null; then kdialog --error "$1" &>/dev/null;
    fi
}

if [[ $EUID -eq 0 ]]; then
    printerror "This program should not be run using sudo or as the root user!\n"
    exit 1
fi


LAUNCHER_NAME=@MeshMC_AppBinaryName@
LAUNCHER_DIR="$(dirname "$(readlink -f "$0")")"
echo "Launcher Dir: ${LAUNCHER_DIR}"

# Makes the launcher use portals for file picking
export QT_QPA_PLATFORMTHEME=xdgdesktopportal

# disable OpenGL and Vulkan launcher features on sharun until https://github.com/VHSgunzo/sharun/issues/35
if [[ -f "${LAUNCHER_DIR}/sharun" ]]; then
    export LAUNCHER_DISABLE_GLVULKAN=1
fi

# Just to be sure...
chmod +x "${LAUNCHER_DIR}/bin/${LAUNCHER_NAME}"

ARGS=("${LAUNCHER_DIR}/${LAUNCHER_NAME}" "${LAUNCHER_DIR}/bin/${LAUNCHER_NAME}")

if [ -f "${LAUNCHER_DIR}/portable.txt" ]; then
    ARGS+=("-d" "${LAUNCHER_DIR}")
fi

ARGS+=("$@")

# Run the launcher
exec -a "${ARGS[@]}"