From 36cea997de8ebe9e7bb54e42adc46cfcd2dfa474 Mon Sep 17 00:00:00 2001 From: rockerbacon Date: Thu, 17 Aug 2023 16:29:48 -0300 Subject: [PATCH 1/2] create utility for cleaner protontricks usage --- step/check_dependencies.sh | 16 ++----- step/configure_steam_wineprefix.sh | 12 ++--- utils/protontricks.sh | 72 ++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 22 deletions(-) create mode 100755 utils/protontricks.sh diff --git a/step/check_dependencies.sh b/step/check_dependencies.sh index 9cf5b13..05c7951 100644 --- a/step/check_dependencies.sh +++ b/step/check_dependencies.sh @@ -10,18 +10,8 @@ if [ -z "$(command -v curl)" ] && [ -z "$(command -v wget)" ]; then missing_deps+=("curl or wget") fi -if [ -z "$(command -v protontricks)" ]; then - if [ -n "$(command -v flatpak)" ]; then - if flatpak info com.github.Matoking.protontricks > /dev/null; then - using_flatpak_protontricks=1 - else - missing_deps+=(protontricks) - fi - else - missing_deps+=(protontricks) - fi -else - using_flatpak_protontricks=0 +if [ ! $("$utils/protontricks.sh" get-release) ]; then + missing_deps+=(protontricks) fi if [ -z "$(command -v zenity)" ]; then @@ -42,7 +32,7 @@ fi os_id=$("$utils/get_os_id.sh") -if [ "$os_id" == "steamos" ] && [ "$using_flatpak_protontricks" == "0" ]; then +if [ "$os_id" == "steamos" ] && [ "$("$utils/protontricks.sh" get-release)" != "flatpak" ]; then log_error "Using non-flatpak Protontricks on SteamOS" "$dialog" errorbox \ "Only Flatpak releases of Protontricks are supported on SteamOS.\nPlease install Protontricks through the Discover app and try again." diff --git a/step/configure_steam_wineprefix.sh b/step/configure_steam_wineprefix.sh index f666c9d..c131114 100644 --- a/step/configure_steam_wineprefix.sh +++ b/step/configure_steam_wineprefix.sh @@ -2,15 +2,9 @@ if [ -n "${game_protontricks[*]}" ]; then log_info "applying protontricks ${game_protontricks[@]}" - if [ "$using_flatpak_protontricks" == "0" ]; then - WINETRICKS="$executable_winetricks" \ - protontricks "$game_appid" -q "${game_protontricks[@]}" \ - | "$dialog" loading "Configuring game prefix\nThis may take a while" - else - flatpak run 'com.github.Matoking.protontricks' \ - "$game_appid" -q "${game_protontricks[@]}" \ - | "$dialog" loading "Configuring game prefix\nThis may take a while" - fi + + "$utils/protontricks.sh" apply "$game_appid" "${game_protontricks[@]}" \ + | "$dialog" loading "Configuring game prefix\nThis may take a while" if [ "$?" != "0" ]; then "$dialog" errorbox \ diff --git a/utils/protontricks.sh b/utils/protontricks.sh new file mode 100755 index 0000000..459f594 --- /dev/null +++ b/utils/protontricks.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +function log_error() { + echo "ERROR: $@" >&2 +} + +function get_release() { + if [ -z "$(command -v protontricks)" ]; then + if [ -n "$(command -v flatpak)" ]; then + if flatpak info com.github.Matoking.protontricks &> /dev/null; then + echo "flatpak" + return 0 + fi + fi + else + echo "system" + return 0 + fi + + return 1 +} + +function do_protontricks() { + release=$(get_release) + + case "$release" in + flatpak) + WINETRICKS='' \ + flatpak run 'com.github.Matoking.protontricks' "$@" + return $? + ;; + system) + protontricks "$@" + return $? + ;; + *) + log_error "Protontricks unavailable" + return 1 + ;; + esac +} + +function apply() { + appid=$1; shift + do_protontricks "$appid" -q "$@" + return $? +} + +function get_prefix() { + do_protontricks -c 'echo $WINEPREFIX' "$1" + return $? +} + +action=$1 +shift + +case "$action" in + get-prefix) + get_prefix "$1" + ;; + get-release) + get_release + ;; + apply) + apply "$@" + ;; + *) + log_error "invalid action '$action'" + exit 1 + ;; +esac + From a813ceccc399a76ea419c15c9ca21f7eac5c843e Mon Sep 17 00:00:00 2001 From: rockerbacon Date: Thu, 17 Aug 2023 16:36:31 -0300 Subject: [PATCH 2/2] get proton prefix location from protontricks --- step/load_gameinfo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/step/load_gameinfo.sh b/step/load_gameinfo.sh index 494ebc4..4a2300f 100644 --- a/step/load_gameinfo.sh +++ b/step/load_gameinfo.sh @@ -28,7 +28,7 @@ if [ ! -d "$steam_library" ]; then exit 1 fi -game_compatdata="$steam_library/steamapps/compatdata/$game_appid" -game_prefix="$game_compatdata/pfx" +game_prefix=$("$utils/protontricks.sh" get-prefix "$game_appid") +game_compatdata=$(dirname "$game_prefix") game_installation="$steam_library/steamapps/common/$game_steam_subdirectory"