From acbd33fb027093c7ff4a0a138eb42e7518eeabf8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 7 Dec 2016 23:15:37 -0500 Subject: open a terminal for SMAPI output on Mac (#183) --- src/StardewModdingAPI/unix-launcher.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/StardewModdingAPI/unix-launcher.sh') diff --git a/src/StardewModdingAPI/unix-launcher.sh b/src/StardewModdingAPI/unix-launcher.sh index 0bfe0d5c..ce732588 100644 --- a/src/StardewModdingAPI/unix-launcher.sh +++ b/src/StardewModdingAPI/unix-launcher.sh @@ -1,7 +1,7 @@ #!/bin/bash # MonoKickstart Shell Script # Written by Ethan "flibitijibibo" Lee -# Modified for StardewModdingAPI by Viz +# Modified for StardewModdingAPI by Viz and Pathoschild # Move to script's directory cd "`dirname "$0"`" @@ -28,7 +28,7 @@ if [ "$UNAME" == "Darwin" ]; then ln -sf mcs.bin.osx mcs cp StardewValley.bin.osx StardewModdingAPI.bin.osx - ./StardewModdingAPI.bin.osx $@ + open -a Terminal ./StardewModdingAPI.bin.osx $@ else if [ "$ARCH" == "x86_64" ]; then ln -sf mcs.bin.x86_64 mcs -- cgit From 7511db4c833f6d25422d4340ff228ab76eba7477 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 10 Dec 2016 00:11:50 -0500 Subject: open terminal on most Linux distros (#183) --- src/StardewModdingAPI/unix-launcher.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/StardewModdingAPI/unix-launcher.sh') diff --git a/src/StardewModdingAPI/unix-launcher.sh b/src/StardewModdingAPI/unix-launcher.sh index ce732588..6def449d 100644 --- a/src/StardewModdingAPI/unix-launcher.sh +++ b/src/StardewModdingAPI/unix-launcher.sh @@ -30,13 +30,30 @@ if [ "$UNAME" == "Darwin" ]; then cp StardewValley.bin.osx StardewModdingAPI.bin.osx open -a Terminal ./StardewModdingAPI.bin.osx $@ else + # get launcher + COMMAND="" if [ "$ARCH" == "x86_64" ]; then ln -sf mcs.bin.x86_64 mcs cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64 - ./StardewModdingAPI.bin.x86_64 $@ + COMMAND="./StardewModdingAPI.bin.x86_64 $@" else ln -sf mcs.bin.x86 mcs cp StardewValley.bin.x86 StardewModdingAPI.bin.x86 - ./StardewModdingAPI.bin.x86 $@ + COMMAND="./StardewModdingAPI.bin.x86 $@" + fi + + # open terminal + if command -v x-terminal-emulator 2>/dev/null; then + x-terminal-emulator -e "$COMMAND" + elif command -v gnome-terminal 2>/dev/null; then + gnome-terminal -e "$COMMAND" + elif command -v xterm 2>/dev/null; then + xterm -e "$COMMAND" + elif command -v konsole 2>/dev/null; then + konsole -e "$COMMAND" + elif command -v terminal 2>/dev/null; then + terminal -e "$COMMAND" + else + $COMMAND fi fi -- cgit From dccd73e4fb86a6af38072ae9a35b404502f4602c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 10 Dec 2016 13:01:58 -0500 Subject: detect which Linux command detects whether a command exists (#183) --- release-notes.md | 2 +- src/StardewModdingAPI/unix-launcher.sh | 40 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/StardewModdingAPI/unix-launcher.sh') diff --git a/release-notes.md b/release-notes.md index 188dd52b..e550a835 100644 --- a/release-notes.md +++ b/release-notes.md @@ -11,7 +11,7 @@ For players: * SMAPI will now intercept mod errors in menu draw code, and exit the menu to prevent your game from crashing. * Fixed the installer not removing TrainerMod from appdata if it's already in the game mods directory. * Fixed the installer not moving mods out of appdata if the game isn't installed on the same Windows partition. - * Fixed the SMAPI terminal not opening by default on Mac. Linux users are out of luck. + * Fixed the SMAPI terminal not opening by default on Linux and Mac. For developers: * Added a reflection API (accessible as `helper.Reflection`) that simplifies robust access to the game's private fields and methods. diff --git a/src/StardewModdingAPI/unix-launcher.sh b/src/StardewModdingAPI/unix-launcher.sh index 6def449d..93e33c78 100644 --- a/src/StardewModdingAPI/unix-launcher.sh +++ b/src/StardewModdingAPI/unix-launcher.sh @@ -30,30 +30,38 @@ if [ "$UNAME" == "Darwin" ]; then cp StardewValley.bin.osx StardewModdingAPI.bin.osx open -a Terminal ./StardewModdingAPI.bin.osx $@ else - # get launcher - COMMAND="" + # choose launcher + LAUNCHER="" if [ "$ARCH" == "x86_64" ]; then ln -sf mcs.bin.x86_64 mcs cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64 - COMMAND="./StardewModdingAPI.bin.x86_64 $@" + LAUNCHER="./StardewModdingAPI.bin.x86_64 $@" else ln -sf mcs.bin.x86 mcs cp StardewValley.bin.x86 StardewModdingAPI.bin.x86 - COMMAND="./StardewModdingAPI.bin.x86 $@" + LAUNCHER="./StardewModdingAPI.bin.x86 $@" + fi + + # 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" fi - # open terminal - if command -v x-terminal-emulator 2>/dev/null; then - x-terminal-emulator -e "$COMMAND" - elif command -v gnome-terminal 2>/dev/null; then - gnome-terminal -e "$COMMAND" - elif command -v xterm 2>/dev/null; then - xterm -e "$COMMAND" - elif command -v konsole 2>/dev/null; then - konsole -e "$COMMAND" - elif command -v terminal 2>/dev/null; then - terminal -e "$COMMAND" + # open SMAPI in terminal + if $COMMAND x-terminal-emulator 2>/dev/null; then + x-terminal-emulator -e "$LAUNCHER" + elif $COMMAND gnome-terminal 2>/dev/null; then + gnome-terminal -e "$LAUNCHER" + elif $COMMAND xterm 2>/dev/null; then + xterm -e "$LAUNCHER" + elif $COMMAND konsole 2>/dev/null; then + konsole -e "$LAUNCHER" + elif $COMMAND terminal 2>/dev/null; then + terminal -e "$LAUNCHER" else - $COMMAND + $LAUNCHER fi fi -- cgit