150 lines
6.2 KiB
Bash
150 lines
6.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
get_bottle() {
|
|
# Simple rule: wine64 for everything, wine32 only for speech APIs
|
|
local architecture="${1:-win64}"
|
|
architecture="${architecture/win/}"
|
|
export WINEPREFIX="$HOME/.local/wine${architecture}"
|
|
}
|
|
|
|
# Note: install_wine function removed - we now use system wine with simplified bottle management
|
|
|
|
winetricks() {
|
|
# Report used packages to the winetricks maintainer so he knows they are being used.
|
|
if ! [[ -e "${XDG_CACHE_HOME:-$HOME/.cache}/winetricks/track_usage" ]]; then
|
|
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/winetricks/"
|
|
echo "1" > "${XDG_CACHE_HOME:-$HOME/.cache}/winetricks/track_usage"
|
|
fi
|
|
# Temporary work around for winetricks git bugs. Requires winetricks be installed from package manager.
|
|
/usr/bin/winetricks "$@"
|
|
return
|
|
# Download or update agm's copy of winetricks
|
|
if [[ ! -e "${winetricksPath}/winetricks" ]]; then
|
|
checkWinetricksUpdate="true"
|
|
download "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
|
|
mv "${cache}/winetricks" "${winetricksPath}"
|
|
chmod 755 "${winetricksPath}/winetricks"
|
|
else
|
|
if [[ "$checkWinetricksUpdate" != "true" ]]; then
|
|
checkWinetricksUpdate="true"
|
|
${winetricksPath}/winetricks --self-update
|
|
fi
|
|
fi
|
|
# Run the requested winetricks parameters
|
|
if command -v FEXLoader &> /dev/null ; then
|
|
WINE="" FEXLoader -- ${winetricksPath}/winetricks "$@"
|
|
else
|
|
${winetricksPath}/winetricks "$@"
|
|
fi
|
|
}
|
|
|
|
install_rhvoice() {
|
|
if [[ -d "${WINEPREFIX}/drive_c/Program Files/Olga Yakovleva/" ]]; then
|
|
return
|
|
fi
|
|
if [[ "$norh" == "true" ]]; then
|
|
# Try to prevent the user from breaking speech
|
|
# Also useful for games that do not work with RHVoice
|
|
if [[ "${defaultVoice}" == "RHVoice" ]]; then
|
|
unset defaultVoice
|
|
fi
|
|
return
|
|
fi
|
|
declare -A RHVoice=(
|
|
[alan]="https://github.com/RHVoice/alan-eng/releases/download/4.0/RHVoice-voice-English-Alan-v4.0.2016.21-setup.exe"
|
|
[bdl]="https://github.com/RHVoice/bdl-eng/releases/download/4.1/RHVoice-voice-English-Bdl-v4.1.2016.21-setup.exe"
|
|
[clb]="https://github.com/RHVoice/clb-eng/releases/download/4.0/RHVoice-voice-English-Clb-v4.0.2016.21-setup.exe"
|
|
[lyubov]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Lyubov-v4.0.2008.15-setup.exe"
|
|
[slt]="https://github.com/RHVoice/slt-eng/releases/download/4.1/RHVoice-voice-English-Slt-v4.1.2016.21-setup.exe"
|
|
)
|
|
voiceName="${voiceName:-bdl}"
|
|
voiceName="${voiceName,,}"
|
|
if [[ "${RHVoice[${voiceName}]}" == "" ]]; then
|
|
echo "Invalid RHVoice name specified, defaulting to Bdl."
|
|
voiceName="bdl"
|
|
fi
|
|
local voiceFile="${RHVoice[${voiceName}]##*/}"
|
|
download "${RHVoice[${voiceName}]}"
|
|
winetricks -q win8
|
|
echo "Installing RHVoice ${voiceName^}..."
|
|
wine "${cache}/${voiceFile}" &
|
|
sleep 20
|
|
wineserver -k
|
|
}
|
|
|
|
install_wine_bottle() {
|
|
# Simple rule: wine64 for everything, let WOW64 handle 32-bit speech APIs
|
|
local architecture=64
|
|
export WINEARCH="win64"
|
|
|
|
if [[ "$*" =~ speechsdk || "$*" =~ sapi ]]; then
|
|
echo "Using wine64 with WOW64 for speech API compatibility"
|
|
else
|
|
echo "Using wine64 for optimal performance"
|
|
fi
|
|
|
|
export WINEPREFIX="$HOME/.local/wine${architecture}"
|
|
# Modern wine is unified - no separate wine32/wine64 executables
|
|
export WINE="wine"
|
|
export WINESERVER="wineserver"
|
|
# Arguments to the function are dependancies to be installed.
|
|
# Get location of mono and gecko.
|
|
monoPath="$(find /usr/share/wine/ -maxdepth 1 -type d -name mono 2> /dev/null)"
|
|
geckoPath="$(find /usr/share/wine/ -maxdepth 1 -type d -name "gecko" 2> /dev/null)"
|
|
if [[ -z "$monoPath" ]]; then
|
|
download 'http://dl.winehq.org/wine/wine-mono/6.0.0/wine-mono-6.0.0-x86.msi'
|
|
monoPath="${cache}/wine-mono-6.0.0-x86.msi"
|
|
fi
|
|
if [[ -z "$geckoPath" ]]; then
|
|
download 'http://dl.winehq.org/wine/wine-gecko/2.40/wine_gecko-2.40-x86.msi'
|
|
geckoPath="${cache}/wine_gecko-2.40-x86.msi"
|
|
fi
|
|
echo -n "Using "
|
|
wine --version
|
|
DISPLAY="" wineboot -u
|
|
wine msiexec /i z:"$monoPath" /quiet
|
|
wine msiexec /i z:"$geckoPath" /quiet
|
|
if [[ "${*}" =~ (speechsdk|sapi) ]]; then
|
|
install_rhvoice
|
|
fi
|
|
if [[ "${WINEARCH}" == "win64" ]]; then
|
|
download "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd"
|
|
fi
|
|
if [[ "${WINEARCH}" == "win64" ]] && [[ ! -f "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" ]]; then
|
|
cp "${cache}/nvda2speechd" "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd"
|
|
chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd"
|
|
fi
|
|
winetricks -q isolate_home "$@" "${winVer:-win7}" ${winetricksSettings}
|
|
|
|
# Set default voice for speech-enabled games
|
|
if [[ ${#defaultVoice} -ge 2 ]] && [[ "$*" =~ (speechsdk|sapi) ]]; then
|
|
echo "Setting default voice for wine${architecture}."
|
|
"${0%/*}/speech/set-voice.sh" -b "wine${architecture}" -r "${defaultRate:-7}" -v "${defaultVoice}"
|
|
fi
|
|
}
|
|
|
|
add_launcher() {
|
|
local launchSettings="${WINEARCH:-win64}|${1}|${game}"
|
|
shift
|
|
while [[ $# -gt 0 ]]; do
|
|
launchSettings+="|$1"
|
|
shift
|
|
done
|
|
if ! grep -F -q -x "${launchSettings}" "${configFile}" 2> /dev/null ; then
|
|
echo "${launchSettings}" >> "${configFile}"
|
|
sort -o "${configFile}" "${configFile}"
|
|
# Remove .lnk files because they don't work.
|
|
find ~/Desktop -type f -iname '*.lnk' -exec bash -c '
|
|
for f ; do
|
|
mimeType="$(file -b "$f")"
|
|
mimeType="${mimeType%%,*}"
|
|
if [[ "$mimeType" == "MS Windows shortcut" ]]; then
|
|
rm -v "$f"
|
|
fi
|
|
done' _ {} +
|
|
if [[ "${noCache}" == "true" ]]; then
|
|
rm -f "${cache}/${1##*\\}"
|
|
fi
|
|
fi
|
|
}
|