Skip to content

Commit

Permalink
added vkBasalt support and respecting XDG specs - stl config home cha…
Browse files Browse the repository at this point in the history
…nged!
  • Loading branch information
frostworx committed Jul 3, 2020
1 parent f1fadb3 commit c1f6d09
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 31 deletions.
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Just add this program to your steam game command line like:

### game specific use:

When starting a game with **stl** it will check if a config file exists in `$HOME/.stl/$SteamAppId.conf` for the game
The base gamedirectory `STLCFGDIR` will be either `XDG_CONFIG_HOME/stl` or `$HOME/.config/stl` if `XDG_CONFIG_HOME` not set.

When starting a game with **stl** it will check if a config file exists in `$STLCFGDIR/gamecfgs/$SteamAppId.conf` for the game
if it is not available it is created from the default config file (which is automatically created if not found).

When starting the game a small requester will popup (default 2 seconds).
Expand All @@ -27,19 +29,19 @@ This is one single bash script. Just copy it whereever you want, f.e. /usr/local

When you call the script without any arguments from commandline
it will initially create the default config structure
`$HOME/.stl/default_template.conf`
`$STLCFGDIR/default_template.conf`
and a default global config
`$HOME/.stl/global.conf`
`$STLCFGDIR/global.conf`

As `$HOME/.stl/default_template.conf` is the template for creating the game configs
As `$STLCFGDIR/default_template.conf` is the template for creating the game configs
you might want to adjust its options to your needs before use.


## Quickstart:
In the shipped default configs almost everything is disabled.
* at least make sure that STLEDITOR is a valid text editor (per default set to "geany") in `$HOME/.stl/global.conf`
* at least make sure that STLEDITOR is a valid text editor (per default set to "geany") in `$STLCFGDIR/global.conf`
Also enable everything you want in the freshly created
`$HOME/.stl/default_template.conf`
`$STLCFGDIR/default_template.conf`

## Features:

Expand All @@ -52,7 +54,9 @@ Also enable everything you want in the freshly created
* **strace**
* **editor hotkey** for editing the gameconfig
* **open protondb** page for the launched game with the editor
* **automatic ReShade installation and configuration** for launched game (including optional Depth3D shader installation)
* **automatic ReShade installation and configuration** for launched game
* **automatic Depth3D shader installation
* **basic vkBasalt configuration using Depth3D
* **automatically play regular games in side-by-side mode in VR! (including "sbs tweaks"**
* **tweaks**

Expand All @@ -69,6 +73,7 @@ For the optional features you need:
- wget, unzip for optional reshade download, git for pulling optional shaders
- xdotool, xwininfo, vr-video-player for playing regular games side-by-side in VR
- your favourite editor for editor mode and otionally xdg-open for opening the protondb url of started game
- vkbasalt

## Configuration:

Expand All @@ -77,7 +82,7 @@ Described are only the variables which come from **stl**, for all others please

### Global Settings:

`$HOME/.stl/global.conf`
`$STLCFGDIR/global.conf`
- `LOGDIR`: default logfile dir
- `WRITELOG`: write logfile if enabled
- `STLEDITOR`: the texteditor to use for opening the gameconfig
Expand All @@ -90,7 +95,10 @@ Described are only the variables which come from **stl**, for all others please
- `STLLOG=/tmp/$(basename "$0").log`: the stl logfile
- `USETWEAKS`: set to 1 to override settings with tweaks when found
- `CREATETWEAKS`: set to 1 create tweak config templates (just the header) for the launched game if not found

- `DEPTH3DURL`:Depth3D git project
- `CLONE_DEPTH3D`: allow git clone of Depth3D shaderfiles
- `DEPTH3DSRCDIR`: Depth3D sourcefiles

If you do not want to start the editor requester on game launch generally just set `WAITEDITOR=0` - it will be skipped then for all games

### Functions in detail:
Expand Down Expand Up @@ -138,29 +146,35 @@ as root or enable it persistent in sysctl
- `USERESHADE`: set to 1 to start game with ReShade enabled


The required `$HOME/.stl/reshade.conf` is autogenerated on the first run with `INSTALL_RESHADE` enabled.
if `DOWNLOAD_RESHADE` is set to 1 all required files for ReShade are downloaded once into `RESHADESRCDIR`
The required `$STLCFGDIR/reshade.conf` is autogenerated on the first run with `INSTALL_RESHADE` enabled.
If `DOWNLOAD_RESHADE` is set to 1 all required files for ReShade are downloaded once into `RESHADESRCDIR`
of course you can install all files manually as well. make sure to rename all files correctly:

**64bit** `d3dcompiler_47.dll`: -> d3dcompiler_47_64.dll
**32bit** `d3dcompiler_47.dll`: -> d3dcompiler_47_32.dll
`ReShade64.dll`, `ReShade32.dll`: renaming not required as they will be placed in the gamedir under the required name


the required architecture is autodetected from the game.exe and the matching files are copied from RESHADESRCDIR into the selected game dir
The required architecture is autodetected from the game.exe and the matching files are copied from RESHADESRCDIR into the selected game dir
both downloadfiles and basic configuration were taken from [r/linux_gaming](https://www.reddit.com/r/linux_gaming/comments/b2hi3g/reshade_working_in_wine_43)

#### [vkBasalt](https://github.com/DadSchoorse/vkBasalt)
- `ENABLE_VKBASALT`: set to 1 to start the game with vkbasalt
- `VKBASALT_CONFIG_FILE`: the vkbasalt source config file - it points per default to `STLCFGDIR/vkBasalt.conf` and is autogenerated if not found
The autogenerated `VKBASALT_CONFIG_FILE` points to the files from `RESHADE_DEPTH3D` so it should have been at least checked out once with `CLONE_DEPTH3D`

#### [Depth3D](https://github.com/BlueSkyDefender/Depth3D)
- `RESHADE_DEPTH3D`: set to 1 to install ReShade Depth3D Shader into gamedir

if `CLONE_DEPTH3D` is set to 1 the git repository will be automatically cloned/pulled (only when `RESHADE_DEPTH3D=1`)
with `RESHADE_DEPTH3D` enabled `Overwatch.fxh`, `SuperDepth3D.fx`, `SuperDepth3D_VR.fx` from Depth3D are copied to the gamedir.
If `CLONE_DEPTH3D` is set to 1 the git repository will be automatically cloned/pulled (only when `RESHADE_DEPTH3D=1`) to `DEPTH3DSRCDIR`.

With `RESHADE_DEPTH3D` enabled `Overwatch.fxh`, `SuperDepth3D.fx`, `SuperDepth3D_VR.fx` from Depth3D are copied to the gamedir.
when the game started just create a initial profile by selecting the autodetected `SuperDepth3D_VR.fx`

SBS-VR (regular games side-by-side in **VR**):
--------------------------------------------

currently experimental - it often works very good and sometimes not.
Currently experimental - it often works very good and sometimes not.
For me it works good enough to have much fun with it.
- sometimes setting the focus back to the main window or adjusting the direction of the vr view automatically fails (timing)
- sometimes steamvr doesn't start correctly (probably related to the ancient upstream bug, where games fail to start steamvr if not running yet)
Expand Down Expand Up @@ -204,6 +218,9 @@ For now just copy them into your `~/.stl/sbs/` directory if you want to use them
some gamewindows are causing trouble with vr-video-player (f.e. reproducable with `Giana Sisters 2D (350770)`).
I try to exit the SBSVR routines as graceful as possible, keeping the game open.

To play regular games in VR which do not have builtin SBS, you can either enable ReShade or vkBasalt,
where Reshade probably has more features and vkBasalt is probably more stable

#### Tweaks
function similar to above sbs override.
- `USETWEAKS`: set to 1 to override settings with tweaks when found
Expand Down
90 changes: 74 additions & 16 deletions stl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# shellcheck disable=SC2086 # for $STRACEOPTS $CUSTOMCMD_ARGS- *worksforme* for now

PROGNAME="SteamTinkerLaunch"
PROGVERS="v0.90"
PROGVERS="v0.91"
PROJECTPAGE="https://github.com/frostworx/steamtinkerlaunch"

function howto {
Expand All @@ -18,7 +18,7 @@ function howto {
echo ""
echo " game specific use:"
echo "-----------------------"
echo " When starting a game with $(basename "$0") it will check if a config file exists in \$HOME/.stl/\$SteamAppId.conf for the game"
echo " When starting a game with $(basename "$0") it will check if a config file exists in $SteamAppId.conf for the game"
echo " if it is not available it is created from the default config file (which is automatically created if not found)."
echo ""
echo " When starting the game a small requester will popup (default 2 seconds)."
Expand All @@ -33,7 +33,12 @@ else
AID="$SteamAppId"
fi

STLCFGDIR="$HOME/.$(basename "$0")" # base config dir for this script
if [ -z "$XDG_CONFIG_HOME" ]; then
STLCFGDIR="$HOME/.config/$(basename "$0")" # either hardcoded config dir
else
STLCFGDIR="$XDG_CONFIG_HOME/$(basename "$0")" # or in XDG_CONFIG_HOME if the useer set the variable
fi

STLDEFGLOBALCFG="$STLCFGDIR/global.conf" # global config
STLDEFGAMECFG="$STLCFGDIR/default_template.conf" # the default config template used to create new per game configs - will be autocreated if not found
LOGDIR="$STLCFGDIR/logs" # default logfile dir
Expand All @@ -53,10 +58,47 @@ GFD="$(dirname "$GP")" # the absolute directory where the game
#GN="$(basename "$PWD")" # not always correct as we are sometimes in a subdir, so
GN="$(dirname "$(awk -F 'common/' '{print $2}' <<< "$PWD")")" # this is basically the proper game name

#### VKBASALT BLOCK START ####

function usevkBasalt {
if [ "$ENABLE_VKBASALT" -eq 1 ] ; then
writelog "$(date) - ${FUNCNAME[0]} - vkBasalt enabled"
if [ ! -f "$VKBASALT_CONFIG_FILE" ]; then
writelog "$(date) - ${FUNCNAME[0]} - creating default VKBASALT_CONFIG_FILE $VKBASALT_CONFIG_FILE"
{
echo "effects = reshade"
echo "reshadeIncludePath = $STLCFGDIR/Depth3D/Shaders"
echo "reshade = $STLCFGDIR/Depth3D/Shaders/SuperDepth3D_VR.fx"
} >> "$VKBASALT_CONFIG_FILE"
else
writelog "$(date) - ${FUNCNAME[0]} - default VKBASALT_CONFIG_FILE $VKBASALT_CONFIG_FILE already exists"
fi

if [ ! -f "$STLCFGDIR/Depth3D/Shaders/SuperDepth3D_VR.fx" ]; then
writelog "$(date) - ${FUNCNAME[0]} - Depth3D shader $STLCFGDIR/Depth3D/Shaders/SuperDepth3D_VR.fx not found"
if [ "$CLONE_DEPTH3D" -eq 1 ]; then
writelog "$(date) - ${FUNCNAME[0]} - CLONE_DEPTH3D is enabled so checking it out"
checkReShadeDepth3D
else
writelog "$(date) - ${FUNCNAME[0]} - CLONE_DEPTH3D skipping the installation"
export ENABLE_VKBASALT=0
fi
else
writelog "$(date) - ${FUNCNAME[0]} - looks like Depth3D shader is ready at $STLCFGDIR/Depth3D/Shaders/SuperDepth3D_VR.fx"
fi
fi
}

#### VKBASALT BLOCK END ####


#### SBS VR BLOCK START ####

SBSVRVIDEOPLAYER=vr-video-player
SBSVRWINNAME=hellovr # xdotool only searches for partial match, so fortunately this is enough

#SBSVRWINNAME=hellovr # xdotool only searches for partial match, so fortunately this is enough
SBSVRWINNAME=vr-video-player

STEAMVRARGS=(-applaunch 250820)

# returns the windowid of the biggest window of the main proton exe (a/the exe with win drive Z:)
Expand Down Expand Up @@ -335,13 +377,6 @@ function prepareReshadeFiles {
echo "RS_D3D47_32=d3dcompiler_47_32.dll"
echo "RS_64=ReShade64.dll"
echo "RS_32=ReShade32.dll"
echo "##### SideBySide #####"
echo "## Depth3D git project:"
echo "DEPTH3DURL=https://github.com/BlueSkyDefender/Depth3D.git"
echo "## allow git clone of Depth3D shaderfiles :"
echo "#CLONE_DEPTH3D=1"
echo "## Depth3D sourcefiles:"
echo "DEPTH3DSRCDIR=$STLCFGDIR/reshade/Depth3D"
} >> "$STLRSCFG"
fi

Expand Down Expand Up @@ -376,24 +411,28 @@ function prepareReshadeFiles {
else
writelog "$(date) - ${FUNCNAME[0]} - DOWNLOAD_RESHADE not enabled"
fi

# make sure Depth3D is even wanted
if [ "$RESHADE_DEPTH3D" -eq 1 ]; then
writelog "$(date) - ${FUNCNAME[0]} - RESHADE_DEPTH3D enabled"
# and then only pull/clone it when CLONE_DEPTH3D is allowed
checkReShadeDepth3D
fi
}

function checkReShadeDepth3D {
if [ "$CLONE_DEPTH3D" -eq 1 ]; then
writelog "$(date) - ${FUNCNAME[0]} - CLONE_DEPTH3D enabled"
if [ -d "$DEPTH3DSRCDIR" ]; then
cd "$DEPTH3DSRCDIR" || die
writelog "$(date) - ${FUNCNAME[0]} - cloning $DEPTH3DURL in $PWD"
LC_ALL="" PATH="/usr/local/bin:/usr/bin" LD_LIBRARY_PATH="" LD_PRELOAD="" git pull
else
cd "$RESHADESRCDIR" || die
cd "$STLCFGDIR" || die
writelog "$(date) - ${FUNCNAME[0]} - cloning $DEPTH3DURL in $PWD"
LC_ALL="" PATH="/usr/local/bin:/usr/bin" LD_LIBRARY_PATH="" LD_PRELOAD="" git clone "$DEPTH3DURL"
fi
fi
fi
}

# install reshade:
Expand Down Expand Up @@ -484,7 +523,9 @@ function installReshade {
export USERESHADE=0
fi
fi
}

function installReshadeDepth3D {
if [ "$RESHADE_DEPTH3D" -eq 1 ]; then
writelog "$(date) - ${FUNCNAME[0]} - copying shaders into gamedir"
find "$DEPTH3DSRCDIR/Shaders/" -maxdepth 1 -name "*.fx*" | while read -r file; do
Expand All @@ -495,10 +536,9 @@ function installReshade {
writelog "$(date) - ${FUNCNAME[0]} - copied $file to $GFD"
fi
done
fi
fi
}


function useReshade {
if [ "$USERESHADE" -eq 1 ]; then
if [ ! -f "$GFD/$RS_D3D47_DEST" ]; then
Expand Down Expand Up @@ -607,6 +647,14 @@ function createDefaultGlobalCfg {
echo "#USETWEAKS=1"
echo "## set to 1 create tweak config templates for the launched game if not found"
echo "#CREATETWEAKS=1"
echo "##### SideBySide #####"
echo "## Depth3D git project:"
echo "DEPTH3DURL=https://github.com/BlueSkyDefender/Depth3D.git"
echo "## allow git clone of Depth3D shaderfiles :"
echo "#CLONE_DEPTH3D=1"
echo "## Depth3D sourcefiles:"
echo "DEPTH3DSRCDIR=$STLCFGDIR/Depth3D"

} >> "$STLDEFGLOBALCFG"
fi
}
Expand All @@ -632,6 +680,8 @@ function createDefaultGameCfg {
echo "USEGAMEMODERUN=1"
echo "## use mangohud:"
echo "#MANGOHUD=1"
echo "## set to 1 to start the game with vkbasalt:"
echo "#ENABLE_VKBASALT=1"
echo "## set radv mode:"
echo "#RADV_PERFTEST=aco"
echo "## start winetricks gui before game launch:"
Expand Down Expand Up @@ -695,6 +745,8 @@ function createGameCfg {
echo "#########"
echo "## set the default config file for DXVK_CONFIG_FILE which is used when found - defaults to config found in $STLDXVKDIR"
echo "#STLDXVKCFG=$STLDXVKDIR/$AID.conf"
echo "## vkbasalt source config file:"
echo "VKBASALT_CONFIG_FILE=$STLCFGDIR/vkBasalt.conf"
cat "$STLDEFGAMECFG"
} >> "$STLGAMECFG"
fi
Expand Down Expand Up @@ -953,9 +1005,15 @@ function launchSteamProtonGame {
# install ReShade if INSTALL_RESHADE is 1
installReshade "$@"

# install Depth3D Shader if RESHADE_DEPTH3D is 1
installReshadeDepth3D

# start game wih Reshade if USERESHADE is 1
useReshade

# start game wih usevkBasalt ENABLE_VKBASALT is 1
usevkBasalt

# override tweak settings if USETWEAKS is 1
checkTweakLaunch

Expand Down

0 comments on commit c1f6d09

Please sign in to comment.