Skip to content

Commit

Permalink
Add option to force use Proton with a custom command
Browse files Browse the repository at this point in the history
In some instances, the logic for checking a Window program can fail. This is used with custom commands to check if we should use Proton/Wine or run it as a native executable.
This adds a checkbox on the game menu to force use Proton with a custom command, which should fix instances where a Windows executable is incorrectly detected as a Linux executable and is not ran correctly.

For #710.
  • Loading branch information
sonic2kk committed Jan 8, 2023
1 parent 6d2efba commit 77e0772
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lang/chinese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_KEEPSTLOPEN="Keep steamtinkerlaunch open after game exit"
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/dutch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1033,4 +1033,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/englishUK.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/french.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/german.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1034,4 +1034,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/italian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/polish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
4 changes: 3 additions & 1 deletion lang/russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,4 +1032,6 @@ DESC_CUSTOMCMDRESHADE="Use ReShade with the custom command instead of the game -
GUI_OTRUSEEXEDIR="Use Custom Executable Directory as Working Directory"
DESC_OTRUSEEXEDIR="Run the command from the same directory as the custom executable, this can help with some programs that need files in the same directory as the executable - If unsure, leave unchecked"
GUI_OTRCUSTWORKINGDIR="Working Directory"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
DESC_OTRCUSTWORKINGDIR="Directory to run the executable from, ignored if executable directory is enabled or if left blank - If unsure, leave blank"
GUI_CUSTOMCMD_FORCEWIN="Force Proton with custom command"
DESC_CUSTOMCMD_FORCEWIN="Run this custom command with Proton even if it is not detected as a Windows program"
23 changes: 19 additions & 4 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v12.12.20230101-2"
PROGVERS="v12.12.20230108-1"
PROGCMD="${0##*/}"
SHOSTL="stl"
GHURL="https://github.com"
Expand Down Expand Up @@ -2698,6 +2698,7 @@ function setDefaultCfgValues {
if [ -z "$CUSTOMCMD_ARGS" ] ; then CUSTOMCMD_ARGS="$NON"; fi
if [ -z "$ONLY_CUSTOMCMD" ] ; then ONLY_CUSTOMCMD="0"; fi
if [ -z "$FORK_CUSTOMCMD" ] ; then FORK_CUSTOMCMD="0"; fi
if [ -z "$CUSTOMCMDFORCEWIN" ] ; then CUSTOMCMDFORCEWIN="0"; fi
if [ -z "$WAITFORCUSTOMCMD" ] ; then WAITFORCUSTOMCMD="0"; fi
if [ -z "$INJECT_CUSTOMCMD" ] ; then INJECT_CUSTOMCMD="0"; fi
if [ -z "$INJECTWAIT" ] ; then INJECTWAIT="0"; fi
Expand Down Expand Up @@ -3197,6 +3198,8 @@ function saveCfg {
echo "ONLY_CUSTOMCMD=\"$ONLY_CUSTOMCMD\""
echo "## $DESC_FORK_CUSTOMCMD"
echo "FORK_CUSTOMCMD=\"$FORK_CUSTOMCMD\""
echo "## $DESC_CUSTOMCMD_FORCEWIN"
echo "CUSTOMCMDFORCEWIN=\"$CUSTOMCMDFORCEWIN\""
echo "## $DESC_WAITFORCUSTOMCMD"
echo "WAITFORCUSTOMCMD=\"$WAITFORCUSTOMCMD\""
echo "## $DESC_INJECT_CUSTOMCMD"
Expand Down Expand Up @@ -4911,6 +4914,7 @@ function AllSettingsEntriesDummyFunction {
--field=" $GUI_CUSTOMCMD_ARGS!$DESC_CUSTOMCMD_ARGS ('CUSTOMCMD_ARGS')" "${CUSTOMCMD_ARGS/#-/ -}" `#CAT_Misc` `#MENU_GAME` \
--field=" $GUI_FORK_CUSTOMCMD!$DESC_FORK_CUSTOMCMD ('FORK_CUSTOMCMD')":CHK "${FORK_CUSTOMCMD/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
--field=" $GUI_ONLY_CUSTOMCMD!$DESC_ONLY_CUSTOMCMD ('ONLY_CUSTOMCMD')":CHK "${ONLY_CUSTOMCMD/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
--field=" $GUI_CUSTOMCMD_FORCEWIN!$DESC_CUSTOMCMD_FORCEWIN ('CUSTOMCMDFORCEWIN')":CHK "${CUSTOMCMDFORCEWIN/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
--field=" $GUI_WAITFORCUSTOMCMD!$DESC_WAITFORCUSTOMCMD ('WAITFORCUSTOMCMD')":NUM "${WAITFORCUSTOMCMD/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
--field=" $GUI_INJECT_CUSTOMCMD!$DESC_INJECT_CUSTOMCMD ('INJECT_CUSTOMCMD')":CHK "${INJECT_CUSTOMCMD/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
--field=" $GUI_INJECTWAIT!$DESC_INJECTWAIT ('INJECTWAIT')":NUM "${INJECTWAIT/#-/ -}" `#CAT_Misc` `#SUB_Checkbox` `#MENU_GAME` \
Expand Down Expand Up @@ -10191,9 +10195,20 @@ function launchCustomProg {
cd "$CUSTDIR" >/dev/null || return
writelog "INFO" "${FUNCNAME[0]} - Changed pwd into the custom directory '$PWD'"
fi

if [ "$(file "$CUSTCOM" | grep -c "PE32")" -eq 1 ] || grep -q ".bat" <<< "$CUSTCOM"; then
writelog "INFO" "${FUNCNAME[0]} - '$CUSTCOM' seems to be a MS Windows program - starting through proton"

# Cannot always rely on `file` to return `PE32` even for Windows executables -- See #710
if [ "$(file "$CUSTCOM" | grep -c "PE32")" -eq 1 ] || grep -q ".bat" <<< "$CUSTCOM" || [ "$CUSTOMCMDFORCEWIN" -eq 1 ]; then
if [ "$CUSTOMCMDFORCEWIN" -eq 1 ]; then
writelog "INFO" "${FUNCNAME[0]} - CUSTOMCMDFORCEWIN is '$CUSTOMCMDFORCEWIN' - User wants to force this custom command as a Windows program"
if [ "$(file "$CUSTCOM" | grep -c "PE32")" -eq 0 ]; then
writelog "WARN" "${FUNCNAME[0]} - Custom command does not appear to be a Windows program by normal SteamTinkerLaunch checks, but CUSTOMCMDFORCEWIN was enabled, so using Proton anyway"
else
writelog "INFO" "${FUNCNAME[0]} - Custom command seems to be a Windows program anyway even though CUSTOMCMDFORCEWIN was enabled"
fi
else
writelog "INFO" "${FUNCNAME[0]} - '$CUSTCOM' seems to be a MS Windows program - starting through proton"
fi

if [ "$USEWICO" -eq 1 ] && [ "$(file "$CUSTCOM" | grep -c "(console)")" -eq 1 ]; then
writelog "INFO" "${FUNCNAME[0]} - '$CUSTCOM' seems to be a MS console program - starting using '$WICO'"
if [ "$FORK_CUSTOMCMD" -eq 1 ]; then
Expand Down

0 comments on commit 77e0772

Please sign in to comment.