From 358f66334df4442f2aba3dd9a4c7e6c113628397 Mon Sep 17 00:00:00 2001 From: Cere Date: Mon, 8 Jul 2024 03:42:47 -0400 Subject: [PATCH] add support for defining custom config path via env variable, updated readme to reflect. --- README.md | 1 + stcs-wrapper.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa8522f..b4599ff 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,5 @@ mkdir "$HOME/.local/share/CereSaves/Timestamps" # Or whatever you changed the va ## Usage * Place a copy of `stcs-config.sh.example` next to the game being executed. * Edit the file, removing the `.example` and filling out the gamename and the location of the savedata to back up. (It can be a file or folder of savedata) + * Note: you may also define a custom configfile path by setting the environment variable `STCS_GAME_CONFIG` prior to executing the wrapper. * Prefix any launch command you wish to invoke with `stcs-wrapper.sh`, similar to how you'd load `mangohud`! \ No newline at end of file diff --git a/stcs-wrapper.sh b/stcs-wrapper.sh index 9f2d9fb..654e2e5 100644 --- a/stcs-wrapper.sh +++ b/stcs-wrapper.sh @@ -2,6 +2,14 @@ # Check for Configs STCS_GLOBAL_CONFIG="$HOME/.local/share/CereSaves/stcs-global-config.sh" +STCS_GAME_CONFIG="./stcs-config.sh" + +if [ -z ${STCS_GAME_CONFIG+x} ]; then + echo "[CereSaves] Game config not defined, trying default!"; + STCS_GAME_CONFIG="./stcs-config.sh" +else + echo "[CereSaves] Game config is set to '$STCS_GAME_CONFIG'"; +fi if [ ! -f "$STCS_GLOBAL_CONFIG" ]; then echo "[CereSaves] Global config not found!" @@ -9,13 +17,13 @@ if [ ! -f "$STCS_GLOBAL_CONFIG" ]; then fi # TODO - find a way to make this not a static filename, for multiple games in one folder. -if [ ! -f "./stcs-config.sh" ]; then +if [ ! -f "$STCS_GAME_CONFIG" ]; then echo "[CereSaves] Game config not found!" exit 1 fi source "$STCS_GLOBAL_CONFIG" -source ./stcs-config.sh +source "$STCS_GAME_CONFIG" STCS_CACHED_TIMESTAMP_PATH="${STCS_TIMESTAMPS_DIR}/${STCS_GAMENAME}.timestamp" STCS_SYNCED_TIMESTAMP_PATH="${STCS_SAVEGAME_SYNCDIR}/${STCS_GAMENAME}.timestamp"