summaryrefslogtreecommitdiff
path: root/package/linux
diff options
context:
space:
mode:
authorMatthew Cline2011-07-17 15:50:31 -0700
committerMatthew Cline2011-07-17 15:50:31 -0700
commit592a65f9a3668926237437233c80888b023c5c94 (patch)
tree7e3ace670c748268a7de515873b4be56519f92ca /package/linux
parent38998a57ca51aa1ca6a9393b0791bbc08d54561c (diff)
downloaddfhack-592a65f9a3668926237437233c80888b023c5c94.tar.gz
dfhack-592a65f9a3668926237437233c80888b023c5c94.tar.bz2
dfhack-592a65f9a3668926237437233c80888b023c5c94.tar.xz
".dfhackrc" user config file
If the file ".dfhackrc" exists in the user's home directory or in the game directory it will be sourced, so the user can set environmental variables like LD_LIBRARY_PATH. There's also a few shell variables it can set to alter the behavior of the dfhack script.
Diffstat (limited to 'package/linux')
-rwxr-xr-xpackage/linux/dfhack37
1 files changed, 33 insertions, 4 deletions
diff --git a/package/linux/dfhack b/package/linux/dfhack
index d5d22187..46d32f52 100755
--- a/package/linux/dfhack
+++ b/package/linux/dfhack
@@ -4,28 +4,53 @@
# changed to properly set LD_PRELOAD so as to run DFHACK.
#
# You can run DF under gdb by passing -g or --gdb as the first argument.
+#
+# If the file ".dfhackrc" exists in the DF directory or your home directory
+# it will be sourced by this script, to let you set environmental variables.
+# If it exists in both places it will first source the one in your home
+# directory, then the on in the game directory.
+#
+# Shell variables .dfhackrc can set to affect this script:
+# DF_GDB_OPTS: Options to pass to gdb, if it's being run
+# DF_VALGRIND_OPTS: Options to pass to valgrind, if it's being run
+# DF_HELGRIND_OPTS: Options to pass to helgrind, if it's being run
+# DF_RESET_OPTS: Options to pass the reset command at the end of
+# this script
+# DF_POST_CMD: Shell command to be run at very end of script
DF_DIR=$(dirname "$0")
cd "${DF_DIR}"
export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.
#export SDL_VIDEO_CENTERED=1 # Centre the screen. Messes up resizing.
+# User config files
+RC=".dfhackrc"
+
+if [ -r "$HOME/$RC" ]; then
+ . $HOME/$RC
+fi
+if [ -r "./$RC" ]; then
+ . "./$RC"
+fi
+
+# Now run
+
case "$1" in
-g | --gdb)
shift
echo "set environment LD_PRELOAD=./libdfhack.so" > gdbcmd.tmp
- gdb -x gdbcmd.tmp ./libs/Dwarf_Fortress $*
+ gdb $DF_GDB_OPTS -x gdbcmd.tmp ./libs/Dwarf_Fortress $*
rm gdbcmd.tmp
ret=$?
;;
-h | --helgrind)
shift
- LD_PRELOAD=./libdfhack.so valgrind --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress $*
+ LD_PRELOAD=./libdfhack.so valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress $*
ret=$?
;;
-v | --valgrind)
shift
- LD_PRELOAD=./libdfhack.so valgrind --log-file=valgrind.log ./libs/Dwarf_Fortress $*
+ LD_PRELOAD=./libdfhack.so valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./libs/Dwarf_Fortress $*
ret=$?
;;
*)
@@ -35,6 +60,10 @@ case "$1" in
esac
# Reset terminal to sane state in case of a crash
-reset
+reset $DF_RESET_OPTS
+
+if [ -n "$DF_POST_CMD" ]; then
+ eval $DF_POST_CMD
+fi
exit $ret