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.

This commit is contained in:
stormdragon2976 2023-02-05 15:37:57 -05:00
parent 6712a9a234
commit 5e1ca7ce7f
2 changed files with 16 additions and 5 deletions

View File

@ -589,6 +589,9 @@ install_wine_bottle() {
chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd"
fi fi
winetricks -q isolate_home $@ ${winVer:-winxp} ${winetricksSettings}; } | dialog --progressbox "Installing wine bottle, please wait..." -1 -1 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"
} }

View File

@ -77,6 +77,14 @@ if [[ -z "${WINEPREFIX}" ]]; then
exit 0 exit 0
fi 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() { msgbox() {
# Returns: None # Returns: None
# Shows the provided message on the screen with an ok button. # Shows the provided message on the screen with an ok button.
@ -124,7 +132,7 @@ menulist() {
restore_voice() { restore_voice() {
if [[ $doRestore -eq 0 ]]; then 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" $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 fi
} }
@ -142,7 +150,7 @@ set_voice() {
RHVoiceName="${RHVoiceName##*/}" RHVoiceName="${RHVoiceName##*/}"
fullVoice="${voiceListFullName[$counter]}" fullVoice="${voiceListFullName[$counter]}"
fullVoice="${fullVoice/RHVoice/RHVoice\\\\${RHVoiceName}}" 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 # Remove any existing rate change for voices
$sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" $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" $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##*/}" RHVoiceName="${RHVoiceName##*/}"
fullVoice="${voiceListFullName[$counter]}" fullVoice="${voiceListFullName[$counter]}"
fullVoice="${fullVoice/RHVoice/RHVoice\\\\${RHVoiceName}}" 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" $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" cat << "EOF" > "${bottle}/drive_c/windows/temp/speak.vbs"
dim speechobject dim speechobject
set speechobject=createobject("sapi.spvoice") 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." 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 EOF
wine cscript "c:\windows\temp\speak.vbs" ${wine} cscript "c:\windows\temp\speak.vbs"
} }
# Handle voice restore, but only if voice changed # Handle voice restore, but only if voice changed
@ -181,7 +189,7 @@ dim speechobject
set speechobject=createobject("sapi.spvoice") set speechobject=createobject("sapi.spvoice")
speechobject.speak "" speechobject.speak ""
EOF EOF
wine cscript "c:\windows\temp\speak.vbs" ${wine} cscript "c:\windows\temp\speak.vbs"
# Create an array of available voices. # Create an array of available voices.
ifs="$IFS" ifs="$IFS"