From 83d57781eb178b4a2faab0e83168008304082957 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Wed, 1 Jun 2022 18:43:32 +0700 Subject: [PATCH] feat: preloader.sh can specify which folder to load. chore: add preloader.sh readme --- apps/Lutris/README.md | 16 ++++++++++++++++ apps/Lutris/preloader.sh | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 apps/Lutris/README.md diff --git a/apps/Lutris/README.md b/apps/Lutris/README.md new file mode 100644 index 0000000..0356b34 --- /dev/null +++ b/apps/Lutris/README.md @@ -0,0 +1,16 @@ +# Lutris scripts +## `preloader.sh` +Execute multiple scripts in a folder (default is `./preloader`), usually useful for Lutris Pre-launch/Post-exit script ++ This script will execute scripts in **current directory** *(where `preloader.sh` is executed)*, so for example if a script need a file called `nightmare`, and preloader.sh is in `~`, **put it in `~`** instead of `~/preloader/nightmare` +### Installation ++ To download `preloader.sh` itself: +```sh +curl -OL https://gitlab.com/tretrauit/scripts/-/raw/main/apps/Lutris/preloader.sh +chmod +x preloader.sh +``` ++ After that, copy/move this script to the game prefix you want to use, then in Lutris: + - Set pre-launch script in Lutris to where `preloader.sh` is located. + - Disable **Wait for pre-launch script completion** + - *(Optional)* Enable **Disable Lutris Runtime** + ++ Enjoy :L diff --git a/apps/Lutris/preloader.sh b/apps/Lutris/preloader.sh index 230b596..dbe5c97 100755 --- a/apps/Lutris/preloader.sh +++ b/apps/Lutris/preloader.sh @@ -2,6 +2,7 @@ # Lutris pre-loader script, for allowing loading multiple pre-load scripts. # Enabling debug will enable the script output. +FOLDER="./preloader" DEBUG=1 execute_file () { @@ -12,13 +13,13 @@ execute_file () { else # No this is not as smart as you think... filename=$(echo "$1" | cut -d "/" -f3) - nohup "$1" > ./logs/preloader_"$filename".log 2>&1 & + nohup "$1" > ./logs/"$FOLDER"_"$filename".log 2>&1 & fi } echo "Checking directory..." -mkdir -p ./preloader/ ./logs/ -for file in ./preloader/*.*; do +mkdir -p "$FOLDER" ./logs/ +for file in "$FOLDER"/*.*; do [ -e "$file" ] || continue echo "Found $file, loading..." execute_file "$file"