summarylogtreecommitdiffstats
path: root/bgb
diff options
context:
space:
mode:
authorQuint Guvernator2021-12-14 04:01:19 +0100
committerQuint Guvernator2021-12-14 04:01:19 +0100
commita5a3f9fc367d2d4a53220ed322a09cb8ddcc8dc9 (patch)
treed85ca5c0848b8101b5fcb5435d1184102b873214 /bgb
parentcae044cf72cb205567eb0b5635fcc614801d9531 (diff)
downloadaur-a5a3f9fc367d2d4a53220ed322a09cb8ddcc8dc9.tar.gz
accept environment variables in runner script
Diffstat (limited to 'bgb')
-rwxr-xr-xbgb44
1 files changed, 34 insertions, 10 deletions
diff --git a/bgb b/bgb
index fed85b076167..c0eda5a25c43 100755
--- a/bgb
+++ b/bgb
@@ -1,20 +1,44 @@
#!/bin/sh
+#
+# run the gameboy emulator "bgb" in wine
+#
+# environment variables:
+# BGB_CONFIG_PATH=... override the path of the bgb.ini file
+# BGB_SAVE_CONFIG=false skip saving GUI configuration changes
+# BGB_EXE_PATH=... override the path to bgb.exe
+# BGB_DEBUGMSG_DIR=... override the path where debugmsg*.txt will be saved
+# BGB_SAVE_DEBUGMSG=false skip saving debugmsg*.txt files
set -e
-BGB_EXE=/usr/lib/bgb/bgb.exe
-BGB_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/bgb"
-BGB_CONFIG="$BGB_CONFIG_DIR/bgb.ini"
+if [ -z "$BGB_EXE_PATH" ]; then
+ BGB_EXE_PATH=/usr/lib/bgb/bgb.exe
+fi
-mkdir -p "$BGB_CONFIG_DIR"
+if [ -z "$BGB_CONFIG_PATH" ]; then
+ BGB_CONFIG_PATH="${XDG_CONFIG_HOME:-$HOME/.config}/bgb/bgb.ini"
+fi
+
+if [ -z "$BGB_DEBUGMSG_DIR" ]; then
+ BGB_DEBUGMSG_DIR=.
+fi
tmp="$(mktemp -d)"
-cp -t "$tmp" "$BGB_EXE"
-if [ -e "$BGB_CONFIG" ]; then
- cp -t "$tmp" "$BGB_CONFIG"
+cp "$BGB_EXE_PATH" "$tmp/bgb.exe"
+
+if [ -e "$BGB_CONFIG_PATH" ]; then
+ cp "$BGB_CONFIG_PATH" "$tmp/bgb.ini"
fi
-wine "$tmp/$(basename "$BGB_EXE")" $@
+wine "$tmp/bgb.exe" "$@"
+
+if [ "$BGB_SAVE_DEBUGMSG" != false ]; then
+ mkdir -p "$(dirname "$BGB_DEBUGMSG_DIR")"
+ cp -t "$BGB_DEBUGMSG_DIR" "$tmp"/debugmsg*.txt || true
+fi
+
+if [ "$BGB_SAVE_CONFIG" != false ] && [ -e "$tmp/bgb.ini" ]; then
+ mkdir -p "$(dirname "$BGB_CONFIG_PATH")"
+ cp "$tmp/bgb.ini" "$BGB_CONFIG_PATH"
+fi
-cp -t "$BGB_CONFIG_DIR" "$tmp/$(basename "$BGB_CONFIG")"
-cp -t . "$tmp"/debugmsg*.txt || true
rm -r "$tmp"