random-scripts/games/sse-nxmhandler-wrapper.sh

36 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env zsh
# WARNING!! This file is not well written. It probably only works on my setup,
# with Lutris thinking it's running Skyrim from GOG, but really running MO2
local conf_file="${HOME}/.config/lutris/games/the_elder_scrolls_v_skyrim_special_edition-1703312623.yml"
local wine_ver="$(cat "${conf_file}" | yq -r ".wine.version")"
local wine_bin
if [[ -d "${HOME}/.local/share/Steam/compatibilitytools.d/${wine_ver}" ]]; then
wine_bin="${HOME}/.local/share/Steam/compatibilitytools.d/${wine_ver}/files/bin"
elif [[ -d "${HOME}/.local/share/lutris/runners/wine/${wine_ver}" ]]; then
wine_bin="${HOME}/.local/share/lutris/runners/wine/${wine_ver}/bin"
fi
local wine="${wine_bin}/wine"
local wineserver="${wine_bin}/wineserver"
let server_pid="$(pgrep -xf "${wineserver}" | head -n1)"
local server_env_arr=(${(0)"$(</proc/${server_pid}/environ)"})
typeset -A server_env
for entry in ${server_env_arr}; do
local parts=(${(ps:=:)entry})
eval "server_env[${(q)parts[1]}]=${(q)${(j:=:)${parts:1}}}"
done
for var in DISPLAY WINEPREFIX WINEFSYNC; do
export "${var}=${server_env[$var]}"
done
"${wine}" "C:\\Modding\\MO2\\nxmhandler.exe" "${@}"