From f986d5605acfd2cfbdb672a60c5a6505665df207 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Thu, 10 Nov 2022 20:09:23 -0500 Subject: [PATCH 01/24] RS Games is finiky on some computers, attempted fix. --- audiogame-manager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index f8835c4..a1b012c 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -825,7 +825,7 @@ game_launcher() { wine "$winePath\\$wineExec" exit 0 fi - if [[ "$game" =~ screaming-strike-2 ]]; then + if [[ "$game" =~ rs-games ]] || [[ "$game" =~ screaming-strike-2 ]]; then pushd "$(winepath "$winePath")" wine "$wineExec" popd From 2f92150c10f481206d5ff962fe67dfc4e3b088be Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 11 Nov 2022 16:09:38 -0500 Subject: [PATCH 02/24] Added translate-shell to the -c flag. --- audiogame-manager.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index a1b012c..54a7927 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -252,6 +252,12 @@ checklist() { errorList+=("Warning: Sox is not installed. Audio will not work.") fi packageList+=("sox") + if command -v trans &> /dev/null ; then + [[ $# -eq 0 ]] && echo "Translate-shell is installed." + else + errorList+=("Warning: translate-shell is not installed. Games that require translation will not be translated.") + fi + packageList+=("translate-shell") if command -v unix2dos &> /dev/null ; then [[ $# -eq 0 ]] && echo "Dos2unix is installed." else From 7d7a3108ddc7621d5e16b45d25e1587c25301fd6 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 14 Nov 2022 08:07:30 -0500 Subject: [PATCH 03/24] Moved the sequence storm reader to a more generic clipboard_reader.sh script. There very well could be bugs, so please report if you find them. --- audiogame-manager.sh | 58 +------------------------------------- speech/clipboard_reader.sh | 44 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 57 deletions(-) create mode 100755 speech/clipboard_reader.sh diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 54a7927..1bb6f29 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -130,62 +130,6 @@ desktop_launcher() { exit 0 } -# Create the clipboard reading function for Sequence Storm -write_sequence_storm_reader() { -if -e ~/.SequenceStormReader ]]; then - return - fi -# Here-document start -cat << "EOF" > ~/.SequenceStormReader -#!/usr/bin/env bash - -# Wait for the game to be launched -while ! pgrep -u "$USER" ^SequenceStorm &> /dev/null ; do - sleep 0.05 -done - -export DISPLAY=:0 -unset cliptext -socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")" -while pgrep -u "$USER" ^SequenceStorm &> /dev/null ; do - if [[ "$(uname)" == "Darwin" ]]; then - tmp="$(pbpaste 2> /dev/null)" - else - tmp="$(xclip -selection clipboard -o 2> /dev/null)" - fi - tmp="${tmp//%/ percent }" - if [ "$tmp" != "$cliptext" ] ; then - cliptext="$tmp" - if [[ "${cliptext,,}" =~ key|load|private|says|terminal ]]; then - if [[ "$(uname)" == "Darwin" ]]; then - say -v alex -r 300 "$cliptext" - else - if [[ -w "${socketFile}" ]]; then - echo "<#APPEND#>$cliptext" | socat - UNIX-CLIENT:"${socketFile}" - else - spd-say -w -r 50 -- "$cliptext" - fi - fi - else - if [[ "$(uname)" == "Darwin" ]]; then - say -v alex -r 300 "$cliptext" - else - if [[ -w "${socketFile}" ]]; then - echo "$cliptext" | socat - UNIX-CLIENT:"${socketFile}" - else - spd-say -r 50 -- "$cliptext" - fi - fi - fi - fi - sleep 0.05 -done - -exit 0 -EOF -# Here-document end - chmod 755 ~/.SequenceStormReader -} # Wine configuration section @@ -821,7 +765,7 @@ game_launcher() { "${0%/*}/speech/speak_window_title.sh" trtr.exe & fi if [[ "$game" =~ sequence-storm ]]; then - [[ -x ~/.SequenceStormReader ]] && ~/.SequenceStormReader & + "${0%/*}/speech/clipboard_reader.sh" SequenceStorm & fi if [[ "$game" =~ audiodisc ]]; then wine "$winePath\\$wineExec" diff --git a/speech/clipboard_reader.sh b/speech/clipboard_reader.sh new file mode 100755 index 0000000..2ca97a4 --- /dev/null +++ b/speech/clipboard_reader.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Wait for the game to be launched +while ! pgrep -u "$USER" ^$1 &> /dev/null ; do + sleep 0.05 +done + +unset cliptext +socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")" +while pgrep -u "$USER" ^$1 &> /dev/null ; do + if [[ "$(uname)" == "Darwin" ]]; then + tmp="$(pbpaste 2> /dev/null)" + else + tmp="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)" + fi + tmp="${tmp//%/ percent }" + if [ "$tmp" != "$cliptext" ] ; then + cliptext="$tmp" + if [[ "${cliptext,,}" =~ key|load|private|says|terminal ]]; then + if [[ "$(uname)" == "Darwin" ]]; then + say -v alex -r 300 "$cliptext" + else + if [[ -w "${socketFile}" ]]; then + echo "<#APPEND#>$cliptext" | socat - UNIX-CLIENT:"${socketFile}" + else + spd-say -w -r 50 -- "$cliptext" + fi + fi + else + if [[ "$(uname)" == "Darwin" ]]; then + say -v alex -r 300 "$cliptext" + else + if [[ -w "${socketFile}" ]]; then + echo "$cliptext" | socat - UNIX-CLIENT:"${socketFile}" + else + spd-say -r 50 -- "$cliptext" + fi + fi + fi + fi + sleep 0.05 +done + +exit 0 From 728b24f9b480aa000fdc3d4fc08beaf3c747aa8b Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 15 Nov 2022 14:35:49 -0500 Subject: [PATCH 04/24] Quick script to install nvda, specify bottle as argument, default is nvda. --- speech/install_nvda.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 speech/install_nvda.sh diff --git a/speech/install_nvda.sh b/speech/install_nvda.sh new file mode 100755 index 0000000..579d45b --- /dev/null +++ b/speech/install_nvda.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +export DISPLAY=${DISPLAY:-:0} +export WINEARCH=win32 +export WINEPREFIX=~/.local/wine/${1:-nvda} + +winetricks msaa riched20 riched30 win7 + +[[ -f ~/Downloads/nvda_2017.3.exe ]] || wget -O ~/Downloads/nvda_2017.3.exe https://www.nvaccess.org/download/nvda/releases/2017.3/nvda_2017.3.exe +wine ~/Downloads/nvda_2017.3.exe From 39bd8b4f62842b1bfe9876e483c0b40d628bf160 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 15 Nov 2022 22:24:23 -0500 Subject: [PATCH 05/24] Finally got Dragon Pong working. --- audiogame-manager.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 1bb6f29..c4fe07d 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -726,6 +726,13 @@ game_launcher() { fi fi # for games that require custom scripts before launch or custom launch parameters + if [[ "$game" =~ dragon-pong ]]; then + "${0%/*}/speech/speak_window_title.sh" DragonPong.exe & + pushd "$(winepath "$winePath")" + wine "$wineExec" + popd + exit 0 + fi if [[ "$game" =~ haunted-party ]]; then pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd & fi @@ -953,7 +960,7 @@ gameList=( "Death on the Road" "Deathmatch" "Dog Who Hates Toast" - #"Dragon Pong" + "Dragon Pong" "Duck Hunt" "DynaMan" "Easter Quest" @@ -1822,7 +1829,8 @@ case "${game}" in echo "Note: Dog who Hates Toast installed. Once you start the game, you must press tab until you hear sapi on to get speech." >&2 ;; "Dragon Pong") - install_wine_bottle vb6run dx8vb speechsdk + export winVer="win7" + install_wine_bottle download "https://www.iamtalon.me/games/dragonpong.zip" unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/dragonpong.zip" add_launcher "c:\Program Files\dragonpong\DragonPong.exe" From 433b195ba5f51a5081759fb8ead244802e4fbdba Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 22 Nov 2022 14:22:07 -0500 Subject: [PATCH 06/24] Updated install_nvda.sh to use the internal winetricks. --- speech/install_nvda.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/speech/install_nvda.sh b/speech/install_nvda.sh index 579d45b..3c42f69 100755 --- a/speech/install_nvda.sh +++ b/speech/install_nvda.sh @@ -3,8 +3,9 @@ export DISPLAY=${DISPLAY:-:0} export WINEARCH=win32 export WINEPREFIX=~/.local/wine/${1:-nvda} +export winetricksPath="${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager" -winetricks msaa riched20 riched30 win7 +${winetricksPath}winetricks msaa riched20 riched30 win7 [[ -f ~/Downloads/nvda_2017.3.exe ]] || wget -O ~/Downloads/nvda_2017.3.exe https://www.nvaccess.org/download/nvda/releases/2017.3/nvda_2017.3.exe wine ~/Downloads/nvda_2017.3.exe From 5f3445ca96f8e3ab7c609f31e9401a107e42a4da Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 25 Nov 2022 10:55:22 -0500 Subject: [PATCH 07/24] Move the installer script from the fossil repository into here, under the wine directory. --- wine/install-dependencies.sh | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 wine/install-dependencies.sh diff --git a/wine/install-dependencies.sh b/wine/install-dependencies.sh new file mode 100755 index 0000000..9d6b7fc --- /dev/null +++ b/wine/install-dependencies.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# Immediately exit if errors are encountered. +set -e + +# Installer/configuration tool for wine +# If this fails on your system, please contact storm_dragon@linux-a11y.org + +is_function() { + LC_ALL=C type "$1" 2> /dev/null | grep -q "$1 is a function" +} + +configure_arch() { + packageList=( + cabextract + dialog + dos2unix + gawk + unzip + w3m + wget + wine + winetricks + wine_gecko + wine-mono + sdl2 + ncurses + mpg123 + libpulse + libpng + libjpeg-turbo + gnutls + alsa-plugins + alsa-lib + mesa + openal + xz + gst-plugins-bad + gst-plugins-good + gst-plugins-ugly + gst-libav + p7zip + ) + if [[ "$(uname -m)" == "x86_64" ]]; then + # Enable multilib + sudo sed -i '/^#\[multilib\]$/{{N;s/^#\[multilib\]\n#Include = \/etc\/pacman.d\/mirrorlist$/[multilib]\nInclude = \/etc\/pacman.d\/mirrorlist/;t;P;D}}' /etc/pacman.conf + # include lib32 packages. + packageList+=( + lib32-sdl2 + lib32-ncurses + lib32-mpg123 + lib32-libpulse + lib32-libpng + lib32-libjpeg-turbo + lib32-gnutls + lib32-alsa-plugins + lib32-alsa-lib + lib32-mesa + lib32-openal + lib32-gst-plugins-good + lib32-gst-plugins-bad + lib32-gst-plugins-ugly + lib32-gst-libav) + fi + # Some of these may fail, so do them in a for loop. + yay -Syy + for i in "${packageList[@]}" ; do + yay -S --needed $i + done +} + +configure_debian() { + packageList=( + dialog + gawk + gstreamer1.0-plugins-bad:i386 + gstreamer1.0-plugins-good:i386 + gstreamer1.0-plugins-ugly:i386 + mono-complete + ncurses5-dev + w3m + winehq-stable + ) + # make sure 32 bit libraries are available + sudo dpkg --add-architecture i386 + sudo apt install --install-recommends ${packageList[*]} +} + + +distro="$(head -1 /etc/issue | cut -d ' ' -f1)" +distro="${distro,,}" + +if is_function configure_${distro} ; then + configure_${distro} +else + echo "${distro^} is not yet supported. If you want it added, please contact storm_dragon@linux-a11y.org" | fold -s -w 72 +fi + +exit 0 From 560b07c18f7ba47d8e003d3c038d7f673e91a1dd Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 25 Nov 2022 11:21:11 -0500 Subject: [PATCH 08/24] Apply swamp patch in installation so you get the correct version. --- audiogame-manager.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index c4fe07d..af3312e 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -2589,9 +2589,9 @@ EOF download "https://www.kaldobsky.com/audiogames/Swamp.zip" unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/Swamp.zip" # make sure the latest version is installed. - #if wget -O "${cache}/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then - #nzip -o -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPatch.zip" - #fi + if wget -O "${cache}/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then + unzip -o -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPatch.zip" + fi wine 'c:\Program Files\swamp\checkup.exe' /verysilent #wine cmd.exe /c 'cd /d c:\Program Files\swamp && Windows32bit.bat' # Delete music if requested. From 307c45766ce9f929565c8ce650b36325e4956f7c Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Tue, 29 Nov 2022 00:01:46 -0500 Subject: [PATCH 09/24] Added noconfirm to install options for yay --- wine/install-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wine/install-dependencies.sh b/wine/install-dependencies.sh index 9d6b7fc..4ec5f5a 100755 --- a/wine/install-dependencies.sh +++ b/wine/install-dependencies.sh @@ -65,7 +65,7 @@ configure_arch() { # Some of these may fail, so do them in a for loop. yay -Syy for i in "${packageList[@]}" ; do - yay -S --needed $i + yay -S --needed --noconfirm $i done } From 1d512ff1299d96723d6387c8da9d5a106922b62d Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Tue, 29 Nov 2022 09:09:48 -0500 Subject: [PATCH 10/24] make sure nvda2speechd is available for bk3. --- audiogame-manager.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index af3312e..c369536 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -1627,7 +1627,9 @@ case "${game}" in export bottle="nyanchan" export winVer="win7" install_wine_bottle - download "https://www.nyanchangames.com/softs/nn3_setup.exe" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd32.dll" + download "https://www.nyanchangames.com/softs/nn3_setup.exe" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd32.dll" + cp "${cache}/nvda2speechd" "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" + chmod +x "${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd" 7z x -o"$WINEPREFIX/drive_c/nyanchangame/bk3" "${cache}/nn3_setup.exe" find "${WINEPREFIX}" -type f -name 'nvdaControllerClient.dll' -exec cp -v "${cache}/nvda2speechd32.dll" "{}" \; add_launcher "c:\nyanchangame\bk3\play.exe" From d08a3358468ef7d033ec7427d0ed8e9e609cb52e Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Sun, 4 Dec 2022 17:08:38 -0500 Subject: [PATCH 11/24] Added game Danger City. --- audiogame-manager.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index c369536..ab56c7c 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -954,6 +954,7 @@ gameList=( "Crazy Party" "Crazy Tennis" "Crime Hunter" + "Danger City" "Danger on the Wheel" #"Dark Destroyer" "Daytona and the Book of Gold" @@ -1777,6 +1778,17 @@ case "${game}" in find "${WINEPREFIX}" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \; add_launcher "c:\Program Files\crime-hunter\ch.exe" ;; + "Danger City") + install_wine_bottle vb6run dx8vb + download "https://www.agarchive.net/games/xl/DangerCityBeta2.exe" + wine "$cache/DangerCityBeta2.exe" /silent & + xdotool sleep 15 key --clearmodifiers --delay 200 Return 2> /dev/null + xdotool sleep 5 key --clearmodifiers --delay 200 Return 2> /dev/null + xdotool sleep 5key --clearmodifiers --delay 200 Return 2> /dev/null + xdotool sleep 10 --clearmodifiers --delay 200 Return 2> /dev/null + wineserver -w + add_launcher 'c:\Program Files\Danger City\dc.exe' + ;; "Danger on the Wheel") export bottle="oriol-gomez" export winVer="win7" From 0f6138151fb5906f67209b217fe1431ebafcae05 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Mon, 5 Dec 2022 11:46:46 -0500 Subject: [PATCH 12/24] Added translate-shell to the dependencies script. --- wine/install-dependencies.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/wine/install-dependencies.sh b/wine/install-dependencies.sh index 4ec5f5a..f1829f6 100755 --- a/wine/install-dependencies.sh +++ b/wine/install-dependencies.sh @@ -34,6 +34,7 @@ configure_arch() { alsa-lib mesa openal + translate-shell xz gst-plugins-bad gst-plugins-good From 6d853ff27f1ff8db72f06a19a9748c215f705fd7 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Mon, 5 Dec 2022 20:07:17 -0500 Subject: [PATCH 13/24] Very experimental changes with clipboard_translator.sh, now requires sqlite3 and perl. --- audiogame-manager.sh | 7 ++- speech/clipboard_translator.sh | 87 +++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index ab56c7c..a306a24 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -739,8 +739,11 @@ game_launcher() { if [[ "$game" =~ laser-breakout ]]; then pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd & fi - if [[ "$game" =~ ^bokurano-daibouken\||bokurano-daibouken-2\| ]]; then - "${0%/*}/speech/clipboard_translator.sh" play.exe & + if [[ "$game" =~ ^bokurano-daibouken-2\| ]]; then + "${0%/*}/speech/clipboard_translator.sh" play.exe bokurano-daibouken2 & + fi + if [[ "$game" =~ ^bokurano-daibouken\| ]]; then + "${0%/*}/speech/clipboard_translator.sh" play.exe bokurano-daibouken & fi if [[ "$game" =~ shadow-line ]]; then find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \; diff --git a/speech/clipboard_translator.sh b/speech/clipboard_translator.sh index 3445913..4122723 100755 --- a/speech/clipboard_translator.sh +++ b/speech/clipboard_translator.sh @@ -1,54 +1,77 @@ #!/usr/bin/env bash -cleanup() { - sort -uo "$dictionaryFile" "$dictionaryFile" -} +# Modified from the script at: +# https://gist.github.com/fdietze/6768a0970d7d732b7fbd7930ccceee2a -trap cleanup EXIT +set -Eeuo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/#:~:text=set%20%2Du,is%20often%20highly%20desirable%20behavior. +shopt -s expand_aliases -# Clear the clipboard so you don't accidently send personal info to the translator. -echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null -export dictionaryFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/translations.txt" -if [[ ! -r "$dictionaryFile" ]]; then - touch "$dictionaryFile" -fi -if [[ $# -ne 1 ]]; then - echo "Usage: $0 application name." +if [[ $# -ne 2 ]]; then + echo "Usage: $0 \"application name\" \"file name\"." + exit 1 fi # Wait for the application to start while ! pgrep -u "$USER" ^$1 &> /dev/null ; do sleep 0.05 done + +fileName="${2,,}" +fileName="${fileName//[[:space:]]/-}.sqlite" +translationFile="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/${fileName}" # Read so long as the application is running while pgrep -u "$USER" ^$1 &> /dev/null ; do - newText="" - translatedText="" - newText="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)" - sleep 0.01 - if [[ "${#newText}" -lt 1 ]]; then - continue - fi - if [[ "${newText}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then - spd-say -- "$newText" + sleep 0.05 + text="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)" + if [[ "${text}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then + spd-say -- "$text" echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null continue fi - export newText - translatedText="$(awk -v originalText="${newText})==:" 'BEGIN { exitCode = 1; FS = "\\)==:\\[" } - $0~originalText { print $2; exitCode = 0; exit} - END { exit exitCode }' "$dictionaryFile")" - if [[ "${#translatedText}" -ge 1 ]]; then - spd-say -- "$translatedText" - echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null + if [[ -z "$text" ]]; then continue fi - translatedText="$(trans -no-autocorrect -b -- "$newText")" - if ! [[ "${newText}" =~ ^[0-9[:punct:]]+$ ]]; then - echo "${newText})==:[${translatedText}" >> "$dictionaryFile" + q() { sqlite3 -column -init "" "$translationFile" "$@" 2> /dev/null ; } + + + if [[ ! -s "$translationFile" ]]; then + rm -f "$translationFile" + cat << EOF | sqlite3 -init "" "$translationFile" 2> /dev/null +.bail on + +CREATE TABLE translations( + text TEXT NOT NULL, + translation TEXT NOT NULL, + + PRIMARY KEY (text) +); +CREATE INDEX translations_text_idx ON translations (text); +EOF fi - spd-say -- "$translatedText" + + + # https://en.wikipedia.org/wiki/Unicode_equivalence#Combining_and_precomposed_characters + # https://www.effectiveperlprogramming.com/2011/09/normalize-your-perl-source/ + alias nfc="perl -MUnicode::Normalize -CS -ne 'print NFC(\$_)'" # composed characters + + # Normalize different unicode space characters to the same space + # https://stackoverflow.com/a/43640405 + alias normalize_spaces="perl -CSDA -plE 's/[^\\S\\t]/ /g'" + alias normalize_unicode="normalize_spaces | nfc" + + textEscaped="$(echo "$text" | sed "s/'/''/g" | normalize_unicode)" # escape single quotes for sqlite + translated="$(q "SELECT translation FROM translations WHERE text = '$textEscaped' LIMIT 1" | sed 's/\s*$//')" + + if [[ -z "$translated" ]]; then + translated="$(trans -no-autocorrect -no-warn -brief "$text" | head -1 | sed 's/\s*$//' | normalize_unicode)" + if [[ -n "$translated" ]]; then + translatedEscaped="$(echo "$translated" | sed "s/'/''/g")" + q "INSERT OR IGNORE INTO translations (text, translation) VALUES ('$textEscaped', '$translatedEscaped')" + fi + fi + + spd-say -- "$translated" echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null done From 1882c07a416f02cdfcdc1b6ddf46cf5fef1b9067 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Mon, 5 Dec 2022 23:58:48 -0500 Subject: [PATCH 14/24] Removed gettext stuff from set-voice.sh. --- speech/set-voice.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/speech/set-voice.sh b/speech/set-voice.sh index 593c8da..f6f9cd6 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -113,12 +113,12 @@ menulist() { for i in "${@}" ; do menuList+=("$i" "$i") done - dialog --backtitle "$(gettext "Use the up and down arrow keys to find the option you want, then press enter to select it.")" \ + dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \ --clear \ --extra-button \ - --extra-label "$(gettext "Test Voice")" \ + --extra-label "Test Voice" \ --no-tags \ - --menu "$(gettext "Please select one")" 0 0 0 "${menuList[@]}" --stdout + --menu "Please select one" 0 0 0 "${menuList[@]}" --stdout return $? } From bf81956b52729e5d5cf5c1395bb88e2f27a7cf0a Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Tue, 6 Dec 2022 00:08:07 -0500 Subject: [PATCH 15/24] Update games that use clipboard_translator.sh to the new format. --- audiogame-manager.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index a306a24..02c9d70 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -747,7 +747,7 @@ game_launcher() { fi if [[ "$game" =~ shadow-line ]]; then find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \; - "${0%/*}/speech/clipboard_translator.sh" play_sr.exe & + "${0%/*}/speech/clipboard_translator.sh" play_sr.exe shadow-line & fi if [[ "$game" =~ bokurano-daibouken-3 ]]; then dictPath="$(winepath "${winePath}")" @@ -762,7 +762,7 @@ game_launcher() { fi if [[ ! -d "${dictPath}/dict" ]] && [[ ! -r "${cache}/bk3-dict.dat" ]]; then find "${WINEPREFIX}/drive_c/nyanchangame/bk3" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \; - "${0%/*}/speech/clipboard_translator.sh" play.exe & + "${0%/*}/speech/clipboard_translator.sh" play.exe bokurano-daibouken3 & fi fi if [[ "$game" =~ bop-it-emulator ]]; then From c373f2d0e5afdd2c70f4a5c35d790fb53ad638ac Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Tue, 6 Dec 2022 00:19:02 -0500 Subject: [PATCH 16/24] Added new translation dependencies to the -c checklist. --- audiogame-manager.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 02c9d70..f0d338a 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -202,6 +202,18 @@ checklist() { errorList+=("Warning: translate-shell is not installed. Games that require translation will not be translated.") fi packageList+=("translate-shell") + if command -v sqlite3 &> /dev/null ; then + [[ $# -eq 0 ]] && echo "Sqlite3 is installed." + else + errorList+=("Warning: sqlite is not installed. Required for games that need to be translated.") + fi + if command -v perl &> /dev/null ; then + [[ $# -eq 0 ]] && echo "Perl is installed." + else + errorList+=("Warning: perl is not installed. Required for games that need to be translated.") + fi + packageList+=("perl") + packageList+=("sqlite") if command -v unix2dos &> /dev/null ; then [[ $# -eq 0 ]] && echo "Dos2unix is installed." else From 1ab8e8620a387e38e0b075d6f3aeebdc4347208d Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Tue, 6 Dec 2022 01:15:23 -0500 Subject: [PATCH 17/24] Fixed a bug in array size check. --- speech/set-voice.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/set-voice.sh b/speech/set-voice.sh index f6f9cd6..9043f46 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -194,7 +194,7 @@ for x in "${voiceListFullName[@]}" ; do done oldVoice="$($grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"' "${WINEPREFIX}/user.reg" | $sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')" exit=1 -if [[ "${voiceList[@]}" -eq 0 ]]; then +if [[ "${#voiceList[@]}" -eq 0 ]]; then dialog --msgbox "No voices found." -1 -1 exit 1 fi From b5ff9b8756e02b895b9147c8708bf825edc14b68 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Thu, 8 Dec 2022 00:47:02 -0500 Subject: [PATCH 18/24] Turn off speech with clipboard utilities and window title reader by creating the file ~/.agmsilent --- speech/clipboard_reader.sh | 5 ++++- speech/clipboard_translator.sh | 5 +++++ speech/speak_window_title.sh | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/speech/clipboard_reader.sh b/speech/clipboard_reader.sh index 2ca97a4..d0c489e 100755 --- a/speech/clipboard_reader.sh +++ b/speech/clipboard_reader.sh @@ -8,6 +8,10 @@ done unset cliptext socketFile="$(find /tmp -maxdepth 1 -name "orca-*.sock")" while pgrep -u "$USER" ^$1 &> /dev/null ; do + sleep 0.05 + if [[ -f ~/.agmsilent ]]; then + continue + fi if [[ "$(uname)" == "Darwin" ]]; then tmp="$(pbpaste 2> /dev/null)" else @@ -38,7 +42,6 @@ while pgrep -u "$USER" ^$1 &> /dev/null ; do fi fi fi - sleep 0.05 done exit 0 diff --git a/speech/clipboard_translator.sh b/speech/clipboard_translator.sh index 4122723..b3df40f 100755 --- a/speech/clipboard_translator.sh +++ b/speech/clipboard_translator.sh @@ -25,6 +25,9 @@ translationFile="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/${fileName}" while pgrep -u "$USER" ^$1 &> /dev/null ; do sleep 0.05 text="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)" + if [[ -f ~/.agmsilent ]]; then + continue + fi if [[ "${text}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then spd-say -- "$text" echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null @@ -75,3 +78,5 @@ EOF spd-say -- "$translated" echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null done + +exit 0 diff --git a/speech/speak_window_title.sh b/speech/speak_window_title.sh index c4a8c6b..eb73553 100755 --- a/speech/speak_window_title.sh +++ b/speech/speak_window_title.sh @@ -9,6 +9,10 @@ done # Read so long as the application is running while pgrep -u "$USER" ^$1 &> /dev/null ; do + sleep 0.05 + if [[ -f ~/.agmsilent ]]; then + continue + fi wnd_focus=$(xdotool getwindowfocus) wnd_title=$(xprop -id $wnd_focus WM_NAME) lookfor='"(.*)"' @@ -20,5 +24,6 @@ while pgrep -u "$USER" ^$1 &> /dev/null ; do old_title="$wnd_title" fi fi - sleep 0.01 done + +exit 0 From 397a7f2c3b767f1a7fe2149d7e4669b9d32deba9 Mon Sep 17 00:00:00 2001 From: Michael Taboada Date: Wed, 14 Dec 2022 10:20:56 -0800 Subject: [PATCH 19/24] Fix bug in install_nvda.sh --- speech/install_nvda.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speech/install_nvda.sh b/speech/install_nvda.sh index 3c42f69..1d0ee61 100755 --- a/speech/install_nvda.sh +++ b/speech/install_nvda.sh @@ -5,7 +5,7 @@ export WINEARCH=win32 export WINEPREFIX=~/.local/wine/${1:-nvda} export winetricksPath="${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager" -${winetricksPath}winetricks msaa riched20 riched30 win7 +${winetricksPath}/winetricks msaa riched20 riched30 win7 [[ -f ~/Downloads/nvda_2017.3.exe ]] || wget -O ~/Downloads/nvda_2017.3.exe https://www.nvaccess.org/download/nvda/releases/2017.3/nvda_2017.3.exe wine ~/Downloads/nvda_2017.3.exe From 56166f974aee7033779265e27f410a5bfd1fe7f7 Mon Sep 17 00:00:00 2001 From: Michael Taboada Date: Wed, 21 Dec 2022 07:22:34 -0800 Subject: [PATCH 20/24] Work on three d velocity, still not working --- audiogame-manager.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index f0d338a..f670aee 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -2719,9 +2719,9 @@ EOF ;; "Three D velocity") export winVer="win10" - install_wine_bottle speechsdk + install_wine_bottle speechsdk faudio vcrun2008 ole32 oleaut32 gdiplus # Dotnet is evil. That is all. - LC_ALL=C winetricks -q dotnet472 + LC_ALL=C winetricks -q dotnet472 xna40 wineserver -k # Ha ha ha. download "https://github.com/munawarb/Three-D-Velocity-Binaries/archive/master.zip" "https://stormgames.wolfe.casa/downloads/nvdaControllerClient32.dll" unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/master.zip" From ccbe475156479bb7e19fb37a39ebf2ccfbff5d46 Mon Sep 17 00:00:00 2001 From: Michael Taboada Date: Thu, 22 Dec 2022 06:59:42 -0800 Subject: [PATCH 21/24] Hopefully have three d velocity working. Please test! --- audiogame-manager.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index f670aee..bd3edfd 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -540,7 +540,7 @@ install_wine_bottle() { { DISPLAY="" wineboot -u wine msiexec /i z:"$monoPath" /quiet wine msiexec /i z:"$geckoPath" /quiet - if [[ "${*}" =~ speechsdk ]]; then + if [[ "${*}" =~ (speechsdk|sapi) ]]; then install_rhvoice fi if [[ "${WINEARCH}" == "win64" ]]; then @@ -1064,7 +1064,7 @@ gameList=( "The Vale" "Thief" "Traders of Known Space" - #"Three D velocity" + "Three D velocity" "Tomb Hunter" "Top Speed 2" "Top Speed 3" @@ -2719,13 +2719,16 @@ EOF ;; "Three D velocity") export winVer="win10" - install_wine_bottle speechsdk faudio vcrun2008 ole32 oleaut32 gdiplus +export WINEARCH=win64 +export norh=false # Must install a voice, and rhvoice works easily with 64 bit. + install_wine_bottle sapi vcrun2008 gdiplus xact dotnet48 xna40 # Dotnet is evil. That is all. - LC_ALL=C winetricks -q dotnet472 xna40 - wineserver -k # Ha ha ha. - download "https://github.com/munawarb/Three-D-Velocity-Binaries/archive/master.zip" "https://stormgames.wolfe.casa/downloads/nvdaControllerClient32.dll" +# LC_ALL=C winetricks -q dotnet48 +# wineserver -k # Ha ha ha. + download "https://github.com/munawarb/Three-D-Velocity-Binaries/archive/master.zip" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd64.dll" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd32.dll" unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/master.zip" - find "${WINEPREFIX}" -type f -name 'nvdaControllerClient32.dll' -exec cp -v "${cache}/nvdaControllerClient32.dll" "{}" \; + find "${WINEPREFIX}" -type f -name 'nvdaControllerClient32.dll' -exec cp -v "${cache}/nvda2speechd32.dll" "{}" \; + find "${WINEPREFIX}" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \; add_launcher "c:\Program Files\Three-D-Velocity-Binaries-master\tdv.exe" ;; "Triple Triad") From dee46cb51ec86fb3b152db410091c77396b39c18 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Fri, 23 Dec 2022 00:54:43 -0500 Subject: [PATCH 22/24] Add exception for autoupdate for ssh users so it doesn't try to update and prompt for pass phrase. --- audiogame-manager.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index bd3edfd..f4d53b6 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -69,7 +69,7 @@ check_news() { # Automatic update function update() { local url="$(git ls-remote --get-url)" - if [[ "$url" =~ ^ssh://|git@ ]] || [[ -z "$url" ]]; then + if [[ "$url" =~ ^ssh://|git@|gitea@ ]] || [[ -z "$url" ]]; then return fi git remote update &> /dev/null From 7f9194828acc9b3d200be3a3357e2332f145d1c0 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Fri, 23 Dec 2022 01:37:27 -0500 Subject: [PATCH 23/24] New flag added, -q, to prevent launching qjoypad. It can be added to configuration file as noqjoypad=true. --- audiogame-manager.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index f4d53b6..c28f41f 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -398,6 +398,7 @@ help() { echo "The syntax is variable=\"value\"" echo echo "noCache=\"true\" # Do not keep downloaded items in the cache." + echo "noqjoypad=\"true\" # Do not launch qjoypad." echo "norh=\"true\" # Do not install RHVoice." echo "redownload=\"true\" # Redownload sources, do not use the version stored in cache." echo "rhvoice=\"voicename\" # Select the voice to be installed (default Bdl)." @@ -731,10 +732,12 @@ game_launcher() { if command -v qjoypad &> /dev/null ; then mkdir -p ~/.qjoypad3 touch "${HOME}/.qjoypad3/${game%|*}.lyt" - if pgrep qjoypad &> /dev/null ; then - qjoypad -T "${game%|*}" 2> /dev/null - else - qjoypad -T "${game%|*}" 2> /dev/null & + if [[ "${noqjoypad}" != "true" ]]; then + if pgrep qjoypad &> /dev/null ; then + qjoypad -T "${game%|*}" 2> /dev/null + else + qjoypad -T "${game%|*}" 2> /dev/null & + fi fi fi # for games that require custom scripts before launch or custom launch parameters @@ -1108,6 +1111,7 @@ declare -A command=( [N]="No cache, delete the installer after it has been extracted." [n]="No RHVoice, do not install RHVoice when the game is installed." [P]="Print a list of packages required by audiogame-manager." + [q]="No qjoypad. Does not launch qjoypad if it is detected." [R]="Redownload. Removes old versions of packages from cache before installing." [r]="Remove a game. This will delete all game data." [t]="Total games. Show how many games are currently available." @@ -1137,6 +1141,9 @@ while getopts "${args}" i ; do N) noCache="true";; n) norh="true";; P) checklist quiet;; + q) + noqjoypad="true" + game_launcher;; R) redownload="true";; r) game_removal;; t) From b115e3759f62e7236e8c0657bd2c4ae2f27015d1 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Fri, 23 Dec 2022 02:12:34 -0500 Subject: [PATCH 24/24] Moving toward sandboxed wine installations. This means set-voice.sh needs to create and run its script inside the wine directory. --- speech/set-voice.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/speech/set-voice.sh b/speech/set-voice.sh index 9043f46..41d9fde 100755 --- a/speech/set-voice.sh +++ b/speech/set-voice.sh @@ -163,12 +163,12 @@ test_voice() { 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 $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" > /tmp/speak.vbs + 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 "z:\tmp\speak.vbs" + wine cscript "c:\windows\temp\speak.vbs" } # Handle voice restore, but only if voice changed @@ -176,12 +176,12 @@ doRestore=1 trap restore_voice SIGINT # In case the user hasn't run a game using sapi in this prefix yet, let's try to initialize all the registry keys properly. -cat << "EOF" > /tmp/speak.vbs +cat << "EOF" > "${bottle}/drive_c/windows/temp/speak.vbs" dim speechobject set speechobject=createobject("sapi.spvoice") speechobject.speak "" EOF -wine cscript "z:\tmp\speak.vbs" +wine cscript "c:\windows\temp\speak.vbs" # Create an array of available voices. ifs="$IFS"