summarylogtreecommitdiffstats
path: root/unreal-engine-5.6.sh
blob: 54ef387e1731b4661dd4a6fe38c3989f329bbf28 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/bash

# Launcher for unreal-engine-src-5.6 (Unreal Engine 5.6).
# Copied from Alexis Belmonte's unreal-engine.sh in the `unreal-engine` AUR package,
# adapted per minor.

if [ "$(id -u)" -eq 0 ]; then
    echo "ERROR: Run this as an unprivileged user; not as root."
    return
fi

if [ -d "${HOME}/.steam/bin" ] && [ ! -L "${HOME}/.steampath" ]; then
    ln -s "${HOME}/.steam/bin" "${HOME}/.steampath"
elif [ ! -d "${HOME}/.steam/bin" ] && [ ! -L "${HOME}/.steampath" ]; then
    mkdir -p "${HOME}/.steam/bin"
    ln -s "${HOME}/.steam/bin" "${HOME}/.steampath"
fi

# Per-minor user-config dir
if [ ! -d "${HOME}/.config/Epic/UnrealEngine/5.6/Intermediate/" ]; then
    mkdir -p "${HOME}/.config/Epic/UnrealEngine/5.6/Intermediate/"
fi

# Preserve upstream typo path (.cnfig) for compatibility with anything that already wrote there
if [ ! -d "${HOME}/.cnfig/Epic/UnrealEngine/5.6/Intermediate/" ]; then
    mkdir -p "${HOME}/.cnfig/Epic/UnrealEngine/5.6/Intermediate/"
fi

if [ ! -f "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop" ]; then
    cp "/usr/share/applications/com.unrealengine.UE5_6Editor.desktop" \
       "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop"
fi

UE5desktopFileChecksum="$(sha256sum "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop" | cut -f 1 -d ' ')"

if [ "${UE5desktopFileChecksum}" == "ChecksumPlaceholder" ]; then
    UE5editorLocation="$(find InstalledLocationPlaceholder -type f -iname 'UnrealEditor')"
    UE5editorPath="$(echo ${UE5editorLocation/UnrealEditor/})"

    sed -i "7c\\Exec=${UE5editorLocation} %F" "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop"
    sed -i "14c\\Path=${UE5editorPath}" "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop"
fi

# Register this engine with UnrealVersionSelector once, from the INSTALLED
# binary so it records the real /opt/unreal-engine-src-5.6 path (the build-time register
# in Setup.sh was stripped because it recorded the transient build tree). This
# is what wires up .uproject file associations: double-click to open in this
# engine, right-click -> Generate Project Files. Stamped per version so it only
# runs on first launch after install/upgrade.
UE5uvsBin="/opt/unreal-engine-src-5.6/Engine/Binaries/Linux/UnrealVersionSelector-Linux-Shipping"
UE5uvsStamp="${HOME}/.config/Epic/UnrealEngine/5.6/.uvs-registered-5.6.1"
if [ -x "${UE5uvsBin}" ] && [ ! -f "${UE5uvsStamp}" ]; then
    if "${UE5uvsBin}" -register -unattended > /dev/null 2>&1; then
        touch "${UE5uvsStamp}"
    fi
fi

gio launch "${HOME}/.local/share/applications/com.unrealengine.UE5_6Editor.desktop"