Last active
October 1, 2021 15:43
-
-
Save frostworx/d2fc821fe12a8eca076da772683d6463 to your computer and use it in GitHub Desktop.
Quick little bash script 'fixVRDash' which fixes this issue https://github.com/ValveSoftware/SteamVR-for-Linux/issues/255
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# shellcheck source=/dev/null | |
# fixVRDash - fixes this issue https://github.com/ValveSoftware/SteamVR-for-Linux/issues/255 | |
# by automating Supreeemes fix found here: https://github.com/ValveSoftware/SteamVR-for-Linux/issues/255#issuecomment-775624892 | |
# all kudos to him! | |
# Pretty harmless, it also creates backups and tries to make sure it wasn't used before but use at your risk | |
# Usage: | |
# just start it (only applies the changes in SteamVR) | |
# Optional parameters (use `sudo`): | |
# if you want to expand the 'steam' script in your $PATH (usually `/usr/bin/steam`) append 's' as command line parameter | |
# if you want to expand the 'steam-native' script in your $PATH (usually `/usr/bin/steam-native`) append 'sn' as command line parameter | |
SQP="/usr/lib/qt/plugins" | |
#SEARCHDIR="$1" | |
SEARCHDIR="SteamVR" | |
function setSteamPath { | |
HSR="$HOME/.steam/root" | |
HSS="$HOME/.steam/steam" | |
if [ -z "${!1}" ]; then | |
if [ -e "${HSR}/${2}" ]; then | |
STPA="${HSR}/${2}" | |
export "$1"="$STPA" | |
elif [ -e "${HSS}/${2}" ];then | |
STPA="${HSS}/${2}" | |
export "$1"="$STPA" | |
else | |
echo "ERROR" "${FUNCNAME[0]} - '$2' not found for variable '$1' in '$HSR' or '$HSS'!" "E" | |
fi | |
fi | |
} | |
function setSteamPaths { | |
setSteamPath "DEFSTEAMAPPSCOMMON" "steamapps/common" | |
setSteamPath "CFGVDF" "config/config.vdf" | |
} | |
function fixVRDash { | |
BL="bin/linux64" | |
BVL="bin/vrwebhelper/linux64" | |
VRWH="$SVRDIR/$BVL/vrwebhelper.sh" | |
if [ ! -f "$VRWH" ]; then | |
echo "Could not find $VRWH - exiting" | |
else | |
if ! grep -q "$SVRDIR" "$VRWH"; then | |
echo "Automatically doing that what Supreeme found out here: https://github.com/ValveSoftware/SteamVR-for-Linux/issues/255#issuecomment-775624892" | |
echo "---------------" | |
echo "Creating backup ${VRWH}-BACKUP" | |
cp "$VRWH" "${VRWH}-BACKUP" | |
echo "Expanding LD_LIBRARY_PATH in '$VRWH' by adding '$SVRDIR/$BL' and '$SVRDIR/$BVL'" | |
sed "s:LD_LIBRARY_PATH=\"\${STEAM:LD_LIBRARY_PATH=\"$SVRDIR/$BL\:$SVRDIR/$BVL\:\${STEAM:g" -i "$VRWH" | |
BLQP="$SVRDIR/$BL/qt/plugins" | |
if [ -d "$BLQP" ] && [ ! -d "${BLQP}.old" ]; then | |
echo "creating backup ${BLQP}.old" | |
mv "$BLQP" "${BLQP}.old" | |
if [ -d "$SQP" ]; then | |
echo "Creating 'plugins'symlink from '$SQP' in '$SVRDIR/$BL/qt'" | |
cd "$SVRDIR/$BL/qt" || die | |
ln -s "$SQP" "plugins" | |
cd - || die | |
else | |
echo "System qt plugins ordner not found under $SQP" | |
fi | |
fi | |
else | |
echo "Looks like you already fixed your Dashboard - exiting" | |
fi | |
if [ -z "$1" ]; then | |
echo "No command line parameter used, so not changing the LD_LIBRARY_PATH for any system steam script" | |
echo "Either choose 's' for 'steam' or 'sn' for 'steam-native' script if you want to change one of them - uses sudo" | |
else | |
if [ "$1" == "s" ]; then | |
STSC="$(which "steam" 2>/dev/null)" | |
if [ ! -f "$STSC" ]; then | |
echo "'steam' script not found in path" | |
exit | |
fi | |
elif [ "$1" == "sn" ]; then | |
STSC="$(which "steam-native" 2>/dev/null)" | |
if [ ! -f "$STSC" ]; then | |
echo "'steam-native' script not found in path" | |
exit | |
fi | |
fi | |
if [ -n "$STSC" ]; then | |
echo "Changing the LD_LIBRARY_PATH in '$STSC'" | |
if ! grep -q "$SVRDIR" "$STSC"; then | |
echo "Creating backup '$SVRDIR/$(basename "$STSC")_BACKUP'" | |
cp "$STSC" "$SVRDIR/$(basename "$STSC")_BACKUP" | |
if ! grep -q "LD_LIBRARY_PATH" "$STSC"; then | |
echo "No LD_LIBRARY_PATH line found in '$STSC' - inserting one after the shebang" | |
sed "s:LD_LIBRARY_PATH=\"\${STEAM:LD_LIBRARY_PATH=\"$SVRDIR/$BL\:$SVRDIR/$BVL\:\${STEAM:g" -i "$VRWH" | |
sudo sed "2 i export LD_LIBRARY_PATH=\"/usr/lib/steam:/usr/lib32/steam:$SVRDIR/$BL:$SVRDIR/$BVL:\${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH\"" -i "$STSC" | |
else | |
echo "Expanding LD_LIBRARY_PATH in '$STSC' by adding '$SVRDIR/$BL' and '$SVRDIR/$BVL'" | |
sudo sed "s:LD_LIBRARY_PATH=\":LD_LIBRARY_PATH=\"$SVRDIR/$BL\:$SVRDIR/$BVL\::g" -i "$STSC" | |
fi | |
else | |
echo "Looks like you already fixed '$STSC'" | |
fi | |
else | |
echo "'$1' is no valid parameter, either choose 's' for 'steam' or 'sn' for 'steam-native' script" | |
fi | |
fi | |
fi | |
} | |
setSteamPaths | |
SVRDIR="$(find "$DEFSTEAMAPPSCOMMON" -mindepth 1 -maxdepth 1 -type d -name "$SEARCHDIR")" | |
if [ ! -d "$SVRDIR" ]; then | |
if [ -f "$CFGVDF" ]; then | |
if ! grep -q "BaseInstallFolder" "$CFGVDF"; then | |
writelog "INFO" "${FUNCNAME[0]} - No additional Steam Libraries configured in '$CFGVDF' - so no need to search in there" | |
else | |
while read -r protondir; do | |
SVRDIR="$protondir" | |
done <<< "$(while read -r SLP; do find "${SLP//\"/}/steamapps/common" -mindepth 1 -maxdepth 1 -type d -name "$SEARCHDIR"; done <<< "$(grep "BaseInstallFolder" "$CFGVDF" | gawk '{print $2}')")" | |
fi | |
fi | |
fi | |
if [ -d "$SVRDIR" ]; then | |
echo "Found $SEARCHDIR in $SVRDIR" | |
if [ "$SEARCHDIR" == "SteamVR" ]; then | |
fixVRDash "$@" | |
else | |
exit | |
fi | |
else | |
echo "Could not find '$SEARCHDIR' - exiting" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment