1#!/bin/sh 2LAUNCHER=$(readlink -f "${0}") 3HERE="$(dirname "${LAUNCHER}")" 4cd "${HERE}/../lib/openra" || exit 1 5 6# APPIMAGE is an environment variable set by the runtime 7# defining the absolute path to the .AppImage file 8if [ -n "${APPIMAGE}" ]; then 9 LAUNCHER=${APPIMAGE} 10 11 # appimaged doesn't update the mime or icon caches when registering AppImages. 12 # Run update-desktop-database and gtk-update-icon-cache ourselves if we detect 13 # that the desktop file has been installed but the handler is not cached 14 if command -v update-desktop-database > /dev/null; then 15 APPIMAGEID=$(printf "file://%s" "${APPIMAGE}" | md5sum | cut -d' ' -f1) 16 LAUNCHER_NAME="appimagekit_${APPIMAGEID}-openra-{MODID}.desktop" 17 LAUNCHER_PATH="${HOME}/.local/share/applications/${LAUNCHER_NAME}" 18 MIMECACHE_PATH="${HOME}/.local/share/applications/mimeinfo.cache" 19 SCHEME="x-scheme-handler/openra-{MODID}-{TAG}" 20 if [ -f "${LAUNCHER_PATH}" ] && ! grep -qs "${SCHEME}=" "${MIMECACHE_PATH}"; then 21 update-desktop-database "${HOME}/.local/share/applications" 22 if command -v gtk-update-icon-cache > /dev/null; then 23 gtk-update-icon-cache ~/.local/share/icons/hicolor/ -t 24 fi 25 fi 26 fi 27fi 28 29# Search for server connection 30PROTOCOL_PREFIX="openra-{MODID}-{TAG}://" 31JOIN_SERVER="" 32if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then 33 JOIN_SERVER="Launch.Connect=${1#${PROTOCOL_PREFIX}}" 34fi 35 36# Run the game 37export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}" 38mono --debug OpenRA.Game.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" Engine.LaunchWrapper="${HERE}/restore-environment.sh" "${JOIN_SERVER}" "$@" 39 40# Show a crash dialog if something went wrong 41if [ $? != 0 ] && [ $? != 1 ]; then 42 ERROR_MESSAGE="{MODNAME} has encountered a fatal error.\nPlease refer to the crash logs and FAQ for more information.\n\nLog files are located in ~/.openra/Logs\nThe FAQ is available at http://wiki.openra.net/FAQ" 43 if command -v zenity > /dev/null; then 44 zenity --no-wrap --error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null 45 elif command -v kdialog > /dev/null; then 46 kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}" 47 elif "${HERE}/gtk-dialog.py" test > /dev/null; then 48 "${HERE}/gtk-dialog.py" error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null 49 else 50 printf "${ERROR_MESSAGE}\n" 51 fi 52 exit 1 53fi 54