Skip to content

Instantly share code, notes, and snippets.

@BETLOG
Created December 1, 2024 05:54
Show Gist options
  • Save BETLOG/4a43c4490bc762871ea21bc6e7ea2e1e to your computer and use it in GitHub Desktop.
Save BETLOG/4a43c4490bc762871ea21bc6e7ea2e1e to your computer and use it in GitHub Desktop.
gumby tool to test steam %command% string > bepinex > valheim
#!/bin/bash
# betlog - 2024-12-01--15-24-38
#
# NOTE: valheim specific: consense all of the useless crap and eval $0 sorcery in:
# denikson-BepInExPack_Valheim-5.4.2202/start_game_bepinex.sh
# and
# BepInEx_unix_5.4.22.0/run_bepinex.sh
# and instead just export the bep exports, forcibly enable native linux graphics acceleration, maybe manipulate the argument string, and run %command%
# Explicitly avoid just shuffling $1 etc and using shift.
# Seems more useful to target & remove particular strings and pass commands/arguments entered before AND after %command%
#
# USE:
# put this script in your valheim directory, next to the valheim executable
# steam > game properties > launch options
# ./bepinex-valheim.sh %command%
# ./bepinex-valheim.sh %command% -console
# ./bepinex-valheim.sh mangohud gamemoderun %command% -console
# etc
#
# LOG: <valheimDirectory>/<this scipt name>.log
#
# possibly related/useful
# https://github.com/ValveSoftware/Dota-2/issues/2018
# https://github.com/ValveSoftware/steam-runtime/blob/master/doc/steamlinuxruntime-known-issues.md
#
# simple linux-only sanity check
[[ -f "${0%/*}/valheim.x86_64" ]] && valheimBaseDir=${0%/*} || { echo -ne "Could not set valheimBaseDir:\\n either your executable isnt called valheim.x86_64\\n or you didn't put this script in the same folder as valheim.x86_64"; exit; }
#
# test alterations to the %command% string
cmd=$(echo "$@"|sed 's|/[^ ]*/SteamLinuxRuntime_soldier/_v2-entry-point --verb=waitforexitandrun -- ||; s|/[^ ]*/SteamLinuxRuntime/scout-on-soldier-entry-point-v2 -- ||')
# ^ works ^
#
# cmd=$(echo "$@"|sed 's|/[^ ]*/SteamLinuxRuntime_soldier/_v2-entry-point --verb=waitforexitandrun -- ||')
# ^ fails ^
#
# cmd=$(echo "$@"|sed 's|/[^ ]*/SteamLinuxRuntime/scout-on-soldier-entry-point-v2 -- ||')
# ^ fails ^
#
#
# log the original and modified launch options string
# do this before bep exports to avoid spam interference
echo --------------------------------
stamp=$(date +%Y-%m-%d--%H-%M-%S)
echo -ne "----------\\n$stamp\\n\\n\$@ :$@\\n\\n\$cmd:$cmd\\n"|tee -a "${0%.*}.log"
echo --------------------------------
#
# enable native linux acceleration methods
valConfig=$valheimBaseDir/valheim_Data/boot.config
# NOTE: I ASSUME this is valid for both vulkan and opengl, probably ignored by windows
# NOTE make sure to insert BEFORE first line (used it at end for a long time, but something i saw recently said START OF FILE)
# NOTE: updates seem to remove this, and the framerate degradation is horrendous, so check/force them in at every start
[[ -z $(grep -o "gfx-enable-gfx-jobs=1" "$valConfig") ]] && sed -i '1s/^/gfx-enable-gfx-jobs=1\n/' "$valConfig"
[[ -z $(grep -o "gfx-enable-native-gfx-jobs=1" "$valConfig") ]] && sed -i '1s/^/gfx-enable-native-gfx-jobs=1\n/' "$valConfig"
#
# bepinex
export DOORSTOP_ENABLE=TRUE
export DOORSTOP_INVOKE_DLL_PATH="$valheimBaseDir/BepInEx/core/BepInEx.Preloader.dll"
export DOORSTOP_CORLIB_OVERRIDE_PATH="$valheimBaseDir/unstripped_corlib"
export LD_LIBRARY_PATH="$valheimBaseDir/doorstop_libs:$LD_LIBRARY_PATH"
export LD_PRELOAD="libdoorstop_x64.so:$LD_PRELOAD"
#
# start valheim
# -----------
eval $cmd
# $cmd
# -----------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment