diff --git a/home/stormux/.local/bin/stormux_launch_helpers.sh b/home/stormux/.local/bin/stormux_launch_helpers.sh index bc0fb52..d5b23a8 100755 --- a/home/stormux/.local/bin/stormux_launch_helpers.sh +++ b/home/stormux/.local/bin/stormux_launch_helpers.sh @@ -107,6 +107,40 @@ start_nvda2speechd() { sleep 0.2 } +download_wine_accessibility_file() { + local fileName="$1" + local sourceUrl="$2" + local outputPath="$3" + local tempPath + + [[ -s "$outputPath" ]] && return 0 + command -v curl > /dev/null 2>&1 || return 1 + + tempPath="${outputPath}.tmp" + printf 'Downloading %s\n' "$fileName" + if curl --fail --show-error --location --connect-timeout 20 --retry 3 --retry-delay 2 --output "$tempPath" "$sourceUrl"; then + mv -f "$tempPath" "$outputPath" + return 0 + fi + + rm -f "$tempPath" + return 1 +} + +ensure_wine_accessibility_files() { + local accessibilityDir="${HOME}/.local/share/stormux/wine-accessibility" + local ipfsGateway="${ipfsGateway:-https://ipfs.stormux.org}" + local nvdaControllerClient32Dll="${ipfsGateway}/ipfs/QmTrRrT4QFKSkZ8ivfUawA6iJ6adEyyogccE3nLDTfSK8u?filename=nvdaControllerClient32.dll" + local nvdaControllerClient64Dll="${ipfsGateway}/ipfs/QmaYE7RFDtwHCiXCVLcuA3esfFx6E7koidtvrck9AwPuuN?filename=nvdaControllerClient64.dll" + local nvda2speechdBinary="${ipfsGateway}/ipfs/QmPxhoNsoFoJC7bCfioBBCcK8tEoSoYpm342z6u7KjFsVz?filename=nvda2speechd" + + mkdir -p "$accessibilityDir" + download_wine_accessibility_file "nvdaControllerClient32.dll" "$nvdaControllerClient32Dll" "${accessibilityDir}/nvdaControllerClient32.dll" || return 1 + download_wine_accessibility_file "nvdaControllerClient64.dll" "$nvdaControllerClient64Dll" "${accessibilityDir}/nvdaControllerClient64.dll" || return 1 + download_wine_accessibility_file "nvda2speechd" "$nvda2speechdBinary" "${accessibilityDir}/nvda2speechd" || return 1 + chmod 755 "${accessibilityDir}/nvda2speechd" +} + stop_nvda2speechd() { local bridgePid="$1" @@ -170,6 +204,9 @@ run_wine_path() { wineDir="$(winepath "${wineTarget%\\*}")" || return 1 wineExec="${wineTarget##*\\}" pushd "$wineDir" > /dev/null || return 1 + if ! ensure_wine_accessibility_files; then + printf 'Wine accessibility bridge files are missing and could not be downloaded.\n' >&2 + fi update_wine_nvda_dlls start_nvda2speechd bridgePid || true wine "$wineExec" || launchStatus=$?