From 5e1ca7ce7fab5a3eba6f518c95e3d4131a773ee9 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Sun, 5 Feb 2023 15:37:57 -0500 Subject: [PATCH] Create a file, agm.conf, in new bottles that contains the path to wine and wineserver. This will make it possible for game helper scripts to work without breaking bottles that require different versions. --- audiogame-manager.sh | 3 +++ speech/set-voice.sh | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 780a75d..94ea230 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -589,6 +589,9 @@ install_wine_bottle() { chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" fi winetricks -q isolate_home $@ ${winVer:-winxp} ${winetricksSettings}; } | dialog --progressbox "Installing wine bottle, please wait..." -1 -1 + # make it easy for game scripts to know which version of wine to use. + echo "WINE=\"${WINE}\"" > "$HOME/.local/wine/${bottle}/agm.conf" + echo "WINESERVER=\"${WINESERVER}\"" >> "$HOME/.local/wine/${bottle}/agm.conf" } diff --git a/speech/set-voice.sh b/speech/set-voice.sh index 41d9fde..f76013a 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -77,6 +77,14 @@ if [[ -z "${WINEPREFIX}" ]]; then exit 0 fi +# Get wine version if available +if [[ -r "${WINEPREFIX}/agm.conf" ]]; then + source "${WINEPREFIX}/agm.conf" + export WINE + export WINESERVER +fi +wine="${WINE:-$(command -v wine)}" + msgbox() { # Returns: None # Shows the provided message on the screen with an ok button. @@ -124,7 +132,7 @@ menulist() { restore_voice() { if [[ $doRestore -eq 0 ]]; then - wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely + ${wine}server -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely $sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" fi } @@ -142,7 +150,7 @@ set_voice() { RHVoiceName="${RHVoiceName##*/}" fullVoice="${voiceListFullName[$counter]}" fullVoice="${fullVoice/RHVoice/RHVoice\\\\${RHVoiceName}}" - wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely + ${wine}server -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely # Remove any existing rate change for voices $sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" $sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg" @@ -161,14 +169,14 @@ test_voice() { RHVoiceName="${RHVoiceName##*/}" fullVoice="${voiceListFullName[$counter]}" fullVoice="${fullVoice/RHVoice/RHVoice\\\\${RHVoiceName}}" - wineserver -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely + ${wine}server -k # If we don't do this it's likely wine will overwrite our reverted change or even clobber the registry key entirely $sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" cat << "EOF" > "${bottle}/drive_c/windows/temp/speak.vbs" dim speechobject set speechobject=createobject("sapi.spvoice") speechobject.speak "This is a test of your chosen voice. It contains multiple sentences and punctuation, and is designed to give a full representation of this voices qualities." EOF - wine cscript "c:\windows\temp\speak.vbs" + ${wine} cscript "c:\windows\temp\speak.vbs" } # Handle voice restore, but only if voice changed @@ -181,7 +189,7 @@ dim speechobject set speechobject=createobject("sapi.spvoice") speechobject.speak "" EOF -wine cscript "c:\windows\temp\speak.vbs" +${wine} cscript "c:\windows\temp\speak.vbs" # Create an array of available voices. ifs="$IFS"