A *lot* of work done on the audiogame-manager refactor. Hopefully getting somewhat close to stability, but I doubt it.

This commit is contained in:
Storm Dragon
2025-08-04 19:42:59 -04:00
parent 76f0c66c96
commit 4d2134b9a9
68 changed files with 109 additions and 154 deletions

View File

@@ -1,44 +1,13 @@
#!/usr/bin/env bash
get_bottle() {
local architecture="${1/win/}"
# Simple rule: wine64 for everything, wine32 only for speech APIs
local architecture="${1:-win64}"
architecture="${architecture/win/}"
export WINEPREFIX="$HOME/.local/wine${architecture}"
# Wine version for bottles
if [[ "$game" =~ entombed ]]; then
install_wine "6.18" "32"
fi
if [[ "$game" =~ rs-games ]]; then
install_wine "7.0" "32"
fi
if [[ "$game" =~ shadow-line ]]; then
install_wine "7.7" "32"
fi
}
install_wine() {
# Requires wine version, e.g. 7.7 and architecture, 32|64
if [[ $# -ne 2 ]]; then
exit 1
fi
# Figure out wineInstallationPath
wineInstallationPath="${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/wine_$2/$1"
export wine="${wineInstallationPath}/bin/wine"
# If the path exists, wine should already be installed.
# Just make sure we didn't wind up with a empty directory for some reason
rmdir "${wineInstallationPath}" 2> /dev/null
if [[ -d "${wineInstallationPath}" ]]; then
return
fi
mkdir -p "${wineInstallationPath}" 2> /dev/null
# This probably does not need to be cached, so download to tmp.
installationFile="$(mktemp)"
local v=$2
v="${v/32/x86}"
v="${v/64/x64}" # Probably wrong, so just a place holder.
# If this goes wrong, bail out
set -e
{ curl -L --output "${installationFile}" "https://www.playonlinux.com/wine/binaries/phoenicis/upstream-linux-x86/PlayOnLinux-wine-${1}-upstream-linux-${v}.tar.gz"
tar xf "${installationFile}" -C "${wineInstallationPath}"; } | agm_progressbox "Wine Installation" "Installing $2 bit Wine version $1."
set +e
}
# 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.
@@ -104,29 +73,22 @@ install_rhvoice() {
}
install_wine_bottle() {
# Wine defaults to 64, so if you need 32 bit, don't forget export WINEARCH=win32
export WINEARCH="${WINEARCH:-win32}"
# Figure out if we are using a specific version of wine
# Simple rule: wine64 for everything, wine32 ONLY for speech APIs (SAPI5 doesn't work in WOW64)
local architecture
if [[ "$*" =~ speechsdk || "$*" =~ sapi ]]; then
architecture=32
export WINEARCH="win32"
echo "Using wine32 for speech API compatibility (SAPI5 broken in WOW64)"
else
architecture=64
export WINEARCH="win64"
echo "Using wine64 for optimal performance"
fi
export WINEPREFIX="$HOME/.local/wine${architecture}"
export wine="${wine:-$(command -v wine)}"
# Set the WINE and WINESERVER environmental variables so winetricks will use the right installation.
export WINE="${wine}"
export WINESERVER="${wine}server"
# Installation paths are based on WINEARCH unless game is set for custom bottle.
local bottle=""
if [[ ${#game} -gt 0 ]]; then
bottle="${game,,}"
bottle="${bottle//[[:space:]]/-}"
if [[ -d "$HOME/.local/wine/${bottle}" ]]; then
echo "$HOME/.local/wine/${bottle} exists. Please remove it before running this installer."
exit 1
fi
fi
if [[ ( -z "$WINEARCH" || "$WINEARCH" == "win64" ) && ! "$*" =~ speechsdk ]]; then
local architecture=64
else
local architecture=32
fi
export WINEPREFIX="$HOME/.local/wine${bottle:+/}${bottle:-$architecture}"
# 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)"
@@ -154,21 +116,13 @@ install_wine_bottle() {
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}
# make it easy for game scripts to know which version of wine to use.
if [[ ${#bottle} -gt 1 ]]; then
echo "WINE=\"${WINE}\"" > "$HOME/.local/wine/${bottle}/agm.conf"
echo "WINESERVER=\"${WINESERVER}\"" >> "$HOME/.local/wine/${bottle}/agm.conf"
echo "Setting default voice for bottle \"${bottle}\" to \"${defaultVoice}\"."
"${0%/*}/speech/set-voice.sh" -b "${bottle}" -r "${defaultRate:-7}" -v "${defaultVoice}"
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
# If default voice is set, change it for the current architecture
if [[ -z "$bottle" ]]; then
if [[ ${#defaultVoice} -ge 2 ]] && [[ "${*}" =~ (speechsdk|sapi) ]]; then
echo "Setting default voice for wine${architecture}."
"${0%/*}/speech/set-voice.sh" -b "${bottle}" -r "${defaultRate:-7}" -v "${defaultVoice}"
fi
fi
}
add_launcher() {