Skip to content

Instantly share code, notes, and snippets.

@Seneral
Last active June 29, 2025 20:32
Show Gist options
  • Save Seneral/d671c8f09ac19a2a914404708d1026e0 to your computer and use it in GitHub Desktop.
Save Seneral/d671c8f09ac19a2a914404708d1026e0 to your computer and use it in GitHub Desktop.
Monado launch script !! Has to be configured !! Configures which OpenVR compatibility layer and which monado build to launch, with support for multiple GPUs, and automatic insertion of launch options
#!/usr/bin/env sh
# Automatically configure OVR interface - config files have to be created beforehand!
OVR="$(echo $1 | tr '[:upper:]' '[:lower:]')"
if [[ $OVR != "steamvr" && $OVR != "xrizer" && $OVR != "opencomposite" ]]; then
OVR=opencomposite
fi
OVR_CFG=~/.config/openvr/openvrpaths.vrpath.$OVR
if [[ -f $OVR_CFG ]]; then
rm ~/.config/openvr/openvrpaths.vrpath
cp $OVR_CFG ~/.config/openvr/openvrpaths.vrpath
else
echo "Cannot automatically set up OpenVR configuration! Check '~/.config/openvr/openvrpaths.vrpath'!"
fi
# Specify install directory of monado
XR_RT="$(echo $2 | tr '[:upper:]' '[:lower:]')"
if [[ $XR_RT != "monado-default" && $XR_RT != "monado-thaytan" ]]; then
XR_RT=monado-default
fi
# In case you have multiple installs manually built:
#MONADO=~/.local/share/$XR_RT # Example install directory
# This is for a default system install:
MONADO=/usr
# Automatically configure selected monado install as OpenXR runtime
if [[ -f "$MONADO/share/openxr/1/openxr_monado.json" ]]; then
rm ~/.config/openxr/1/active_runtime.json
ln -s $MONADO/share/openxr/1/openxr_monado.json ~/.config/openxr/1/active_runtime.json
else
echo "Cannot automatically set up OpenXR configuration! Check '~/.config/openxr/1/active_runtime.json'!"
fi
# Safe performance defaults (e.g. for iGPU)
SCALE=40
GPU_NUM=0
GPU="$(echo $3 | tr '[:upper:]' '[:lower:]')"
if [[ $GPU == "egpu" || $GPU == "dgpu" ]]; then
SCALE=180
GPU_NUM=1 # This is strictly for second, external GPU! Remove DRI_PRIME below if you don't need this
fi
# WARNING: Hardcoded path to the system library of native steam version since that's what most use to play VR
STEAM_RT=~/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper
# Use this one for flatpak (though there might be other problems)
#STEAM_RT=~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamLinuxRuntime_sniper
ENTRY_POINT=$STEAM_RT/_v2-entry-point
if [[ -d $STEAM_RT ]]; then
echo "Trying to modify entry point variables!"
if [[ ! -f $ENTRY_POINT.bak ]]; then
cp $ENTRY_POINT $ENTRY_POINT.bak
fi
INSERT_LINE="exec \"\${here}/\${run}\" \"\$@\""
# IPC for WiVrn and Monado
IPC_ENV="export PRESSURE_VESSEL_FILESYSTEMS_RW=\"\$XDG_RUNTIME_DIR/wivrn_comp_ipc:\$XDG_RUNTIME_DIR/wivrn/comp_ipc:\$XDG_RUNTIME_DIR/monado_comp_ipc\""
# Any other environment variables to set for each game
GPU_ENV="export DRI_PRIME=$GPU_NUM"
sed -i "s|$INSERT_LINE$|# OpenXR launch options\n$IPC_ENV\n$GPU_ENV\n\n$INSERT_LINE|" $ENTRY_POINT
else
echo "Failed to modify entry point variables, update path or manually set game launch options!"
fi
XRT_DEBUG_GUI=1 XRT_COMPOSITOR_COMPUTE=1 XRT_COMPOSITOR_SCALE_PERCENTAGE=$SCALE XRT_CURATED_GUI=1 $MONADO/bin/monado-service
if [[ -d $STEAM_RT ]]; then
echo "Restoring entry point variables!"
if [[ -f $ENTRY_POINT.bak ]]; then
cp $ENTRY_POINT.bak $ENTRY_POINT
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment