diff options
Diffstat (limited to 'src/SMAPI.Installer/assets')
-rw-r--r-- | src/SMAPI.Installer/assets/README.txt | 9 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/unix-install.sh | 2 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/unix-launcher.sh | 109 |
3 files changed, 67 insertions, 53 deletions
diff --git a/src/SMAPI.Installer/assets/README.txt b/src/SMAPI.Installer/assets/README.txt index 0da49a46..c3a7e271 100644 --- a/src/SMAPI.Installer/assets/README.txt +++ b/src/SMAPI.Installer/assets/README.txt @@ -24,19 +24,20 @@ Manual install THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See instructions above instead. If you really want to install SMAPI manually, here's how. -1. Unzip "internal/windows-install.dat" (on Windows) or "internal/unix-install.dat" (on Linux/Mac). - You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent confusion. +1. Unzip "internal/windows-install.dat" (on Windows) or "internal/unix-install.dat" (on + Linux/macOS). You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent + confusion. 2. Copy the files from the folder you just unzipped into your game folder. The `StardewModdingAPI.exe` file should be right next to the game's executable. 3. - Windows only: if you use Steam, see the install guide above to enable achievements and overlay. Otherwise, just run StardewModdingAPI.exe in your game folder to play with mods. - - Linux/Mac only: rename the "StardewValley" file (no extension) to "StardewValley-original", and + - Linux/macOS only: rename the "StardewValley" file (no extension) to "StardewValley-original", and "StardewModdingAPI" (no extension) to "StardewValley". Now just launch the game as usual to play with mods. -When installing on Linux or Mac: +When installing on Linux or macOS: - Make sure Mono is installed (normally the installer checks for you). While it's not required, many mods won't work correctly without it. (Specifically, mods which load PNG images may crash or freeze the game.) diff --git a/src/SMAPI.Installer/assets/unix-install.sh b/src/SMAPI.Installer/assets/unix-install.sh index 6d0c86ce..311c5469 100644 --- a/src/SMAPI.Installer/assets/unix-install.sh +++ b/src/SMAPI.Installer/assets/unix-install.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Run the SMAPI installer through Mono on Linux or Mac. +# Run the SMAPI installer through Mono on Linux or macOS. # Move to script's directory cd "`dirname "$0"`" diff --git a/src/SMAPI.Installer/assets/unix-launcher.sh b/src/SMAPI.Installer/assets/unix-launcher.sh index 1d97d487..a33c0d7f 100644 --- a/src/SMAPI.Installer/assets/unix-launcher.sh +++ b/src/SMAPI.Installer/assets/unix-launcher.sh @@ -37,73 +37,86 @@ if [ "$UNAME" == "Darwin" ]; then ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib libgdiplus.dylib fi + # create bin file + # Note: don't overwrite if it's identical, to avoid resetting permission flags + if [ ! -x StardewModdingAPI.bin.osx ] || ! cmp StardewValley.bin.osx StardewModdingAPI.bin.osx >/dev/null 2>&1; then + cp -p StardewValley.bin.osx StardewModdingAPI.bin.osx + fi + # launch SMAPI - cp StardewValley.bin.osx StardewModdingAPI.bin.osx open -a Terminal ./StardewModdingAPI.bin.osx "$@" else - # choose launcher - LAUNCHER="" + # choose binary file to launch + LAUNCH_FILE="" if [ "$ARCH" == "x86_64" ]; then ln -sf mcs.bin.x86_64 mcs cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64 - LAUNCHER="./StardewModdingAPI.bin.x86_64" + LAUNCH_FILE="./StardewModdingAPI.bin.x86_64" else ln -sf mcs.bin.x86 mcs cp StardewValley.bin.x86 StardewModdingAPI.bin.x86 - LAUNCHER="./StardewModdingAPI.bin.x86" - fi - export LAUNCHER - - # get cross-distro version of POSIX command - COMMAND="" - if command -v command 2>/dev/null; then - COMMAND="command -v" - elif type type 2>/dev/null; then - COMMAND="type -p" + LAUNCH_FILE="./StardewModdingAPI.bin.x86" fi + export LAUNCH_FILE # select terminal (prefer xterm for best compatibility, then known supported terminals) for terminal in xterm gnome-terminal kitty terminator xfce4-terminal konsole terminal termite alacritty mate-terminal x-terminal-emulator; do - if $COMMAND "$terminal" 2>/dev/null; then - export LAUNCHTERM=$terminal + if command -v "$terminal" 2>/dev/null; then + export TERMINAL_NAME=$terminal break; fi done # find the true shell behind x-terminal-emulator - if [ "$LAUNCHTERM" = "x-terminal-emulator" ]; then - export LAUNCHTERM="$(basename "$(readlink -f $(COMMAND x-terminal-emulator))")" + if [ "$TERMINAL_NAME" = "x-terminal-emulator" ]; then + export TERMINAL_NAME="$(basename "$(readlink -f $(command -v x-terminal-emulator))")" fi # run in selected terminal and account for quirks - case $LAUNCHTERM in - terminal|termite) - # LAUNCHTERM consumes only one argument after -e - # options containing space characters are unsupported - exec $LAUNCHTERM -e "env TERM=xterm $LAUNCHER $@" - ;; - xterm|konsole|alacritty) - # LAUNCHTERM consumes all arguments after -e - exec $LAUNCHTERM -e env TERM=xterm $LAUNCHER "$@" - ;; - terminator|xfce4-terminal|mate-terminal) - # LAUNCHTERM consumes all arguments after -x - exec $LAUNCHTERM -x env TERM=xterm $LAUNCHER "$@" - ;; - gnome-terminal) - # LAUNCHTERM consumes all arguments after -- - exec $LAUNCHTERM -- env TERM=xterm $LAUNCHER "$@" - ;; - kitty) - # LAUNCHTERM consumes all trailing arguments - exec $LAUNCHTERM env TERM=xterm $LAUNCHER "$@" - ;; - *) - # If we don't know the terminal, just try to run it in the current shell. - env TERM=xterm $LAUNCHER "$@" - # if THAT fails, launch with no output - if [ $? -eq 127 ]; then - exec $LAUNCHER --no-terminal "$@" - fi - esac + export TERMINAL_PATH="$(command -v $TERMINAL_NAME)" + if [ -x $TERMINAL_PATH ]; then + case $TERMINAL_NAME in + terminal|termite) + # consumes only one argument after -e + # options containing space characters are unsupported + exec $TERMINAL_NAME -e "env TERM=xterm $LAUNCH_FILE $@" + ;; + + xterm|konsole|alacritty) + # consumes all arguments after -e + exec $TERMINAL_NAME -e env TERM=xterm $LAUNCH_FILE "$@" + ;; + + terminator|xfce4-terminal|mate-terminal) + # consumes all arguments after -x + exec $TERMINAL_NAME -x env TERM=xterm $LAUNCH_FILE "$@" + ;; + + gnome-terminal) + # consumes all arguments after -- + exec $TERMINAL_NAME -- env TERM=xterm $LAUNCH_FILE "$@" + ;; + + kitty) + # consumes all trailing arguments + exec $TERMINAL_NAME env TERM=xterm $LAUNCH_FILE "$@" + ;; + + *) + # If we don't know the terminal, just try to run it in the current shell. + # If THAT fails, launch with no output. + env TERM=xterm $LAUNCH_FILE "$@" + if [ $? -eq 127 ]; then + exec $LAUNCH_FILE --no-terminal "$@" + fi + esac + + ## terminal isn't executable; fallback to current shell or no terminal + else + echo "The '$TERMINAL_NAME' terminal isn't executable. SMAPI might be running in a sandbox or the system might be misconfigured? Falling back to current shell." + env TERM=xterm $LAUNCH_FILE "$@" + if [ $? -eq 127 ]; then + exec $LAUNCH_FILE --no-terminal "$@" + fi + fi fi |