add support for defining custom config path via env variable, updated readme to reflect.

This commit is contained in:
Cere 2024-07-08 03:42:47 -04:00
parent 4b1cf209c6
commit 358f66334d
2 changed files with 11 additions and 2 deletions

View File

@ -24,4 +24,5 @@ mkdir "$HOME/.local/share/CereSaves/Timestamps" # Or whatever you changed the va
## Usage ## Usage
* Place a copy of `stcs-config.sh.example` next to the game being executed. * 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) * 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`! * Prefix any launch command you wish to invoke with `stcs-wrapper.sh`, similar to how you'd load `mangohud`!

View File

@ -2,6 +2,14 @@
# Check for Configs # Check for Configs
STCS_GLOBAL_CONFIG="$HOME/.local/share/CereSaves/stcs-global-config.sh" 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 if [ ! -f "$STCS_GLOBAL_CONFIG" ]; then
echo "[CereSaves] Global config not found!" echo "[CereSaves] Global config not found!"
@ -9,13 +17,13 @@ if [ ! -f "$STCS_GLOBAL_CONFIG" ]; then
fi fi
# TODO - find a way to make this not a static filename, for multiple games in one folder. # 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!" echo "[CereSaves] Game config not found!"
exit 1 exit 1
fi fi
source "$STCS_GLOBAL_CONFIG" source "$STCS_GLOBAL_CONFIG"
source ./stcs-config.sh source "$STCS_GAME_CONFIG"
STCS_CACHED_TIMESTAMP_PATH="${STCS_TIMESTAMPS_DIR}/${STCS_GAMENAME}.timestamp" STCS_CACHED_TIMESTAMP_PATH="${STCS_TIMESTAMPS_DIR}/${STCS_GAMENAME}.timestamp"
STCS_SYNCED_TIMESTAMP_PATH="${STCS_SAVEGAME_SYNCDIR}/${STCS_GAMENAME}.timestamp" STCS_SYNCED_TIMESTAMP_PATH="${STCS_SAVEGAME_SYNCDIR}/${STCS_GAMENAME}.timestamp"