]> de.git.xonotic.org Git - xonotic/xonotic.git/blobdiff - xonotic-linux-sdl.sh
Fix macOS SDL2 framework permissions
[xonotic/xonotic.git] / xonotic-linux-sdl.sh
index e4ae857ee80ea6468f30ebffd29325c80e8af302..be8feddf5fd666a502a77840ca8e98c683bd3804 100755 (executable)
@@ -1,23 +1,25 @@
 #!/bin/sh
 
-path=`dirname "${0}"`
-link=`readlink -f "${0}"`
+path=$(dirname "${0}")
+link=$(readlink -f "${0}")
 
-[ -n "${link}" ] && path=`dirname "${link}"`
-cd "${path}"
+[ -n "${link}" ] && path=$(dirname "${link}")
+cd "${path}" || exit 1
 
 case "${0##*/}" in
-  *dedicated*) mode="dedicated" ;;
-  *glx*)       mode="glx" ;;
-  *)           mode="sdl" ;;
+  *dedicated*)  mode="dedicated" ;;
+  *)            mode="sdl" ;;
 esac
 
-case "$(uname -m)" in
-  i?86)        arch="linux32" ;;  # Not supported anymore but you can build your own.
-  *)   arch="linux64" ;;
+case $(uname):$(uname -m) in
+  Linux:x86_64)  arch="linux64" ;;
+  *)             arch="local"   ;;  # Not pre-built but you can build your own
 esac
 
-xonotic="xonotic-${arch}-${mode}"
+# prefer locally built binary if available (see: Makefile)
+xonotic="xonotic-local-${mode}"
+[ -x "$xonotic" ] || xonotic="xonotic-${arch}-${mode}"
+echo "Executing: $xonotic ${*}"
 
 set -- ./${xonotic} "${@}"
 
@@ -119,13 +121,14 @@ case "$xserver" in
                ;;
 esac
 
-# if pulseaudio
-if [ -z "$SDL_AUDIODRIVER" ]; then
-       if ps -C pulseaudio >/dev/null; then
-               if ldd /usr/lib/libSDL.so 2>/dev/null | grep pulse >/dev/null; then
-                       export SDL_AUDIODRIVER=pulse
-               fi
+if which "$1" > /dev/null
+then
+       exec "$@"
+else
+       echo "Could not find $1 to exec"
+       if [ "$arch" = "local" ]
+       then
+               printf "%b\n%b\n" "Xonotic does not currently provide pre-built $(uname):$(uname -m) builds, please compile one using make" \
+                       "More info is available at \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m"
        fi
 fi
-
-exec "$@"