Compare commits

..

25 Commits

Author SHA1 Message Date
stormdragon2976
22e4f89a06 Merge branch 'testing' latest code and bug fixes. Testing branch is
getting ready to do something very experimental.
2022-12-25 13:42:06 -05:00
stormdragon2976
b115e3759f Moving toward sandboxed wine installations. This means set-voice.sh needs to create and run its script inside the wine directory. 2022-12-23 02:12:34 -05:00
stormdragon2976
7f9194828a New flag added, -q, to prevent launching qjoypad. It can be added to configuration file as noqjoypad=true. 2022-12-23 01:37:27 -05:00
stormdragon2976
dee46cb51e Add exception for autoupdate for ssh users so it doesn't try to update and prompt for pass phrase. 2022-12-23 00:54:43 -05:00
ccbe475156 Hopefully have three d velocity working. Please test! 2022-12-22 06:59:42 -08:00
56166f974a Work on three d velocity, still not working 2022-12-21 07:22:34 -08:00
397a7f2c3b Fix bug in install_nvda.sh 2022-12-14 10:20:56 -08:00
stormdragon2976
b5ff9b8756 Turn off speech with clipboard utilities and window title reader by creating the file ~/.agmsilent 2022-12-08 00:47:02 -05:00
stormdragon2976
1ab8e8620a Fixed a bug in array size check. 2022-12-06 01:15:23 -05:00
stormdragon2976
c373f2d0e5 Added new translation dependencies to the -c checklist. 2022-12-06 00:19:02 -05:00
stormdragon2976
bf81956b52 Update games that use clipboard_translator.sh to the new format. 2022-12-06 00:08:07 -05:00
stormdragon2976
1882c07a41 Removed gettext stuff from set-voice.sh. 2022-12-05 23:58:48 -05:00
stormdragon2976
6d853ff27f Very experimental changes with clipboard_translator.sh, now requires sqlite3 and perl. 2022-12-05 20:07:17 -05:00
stormdragon2976
0f6138151f Added translate-shell to the dependencies script. 2022-12-05 11:46:46 -05:00
stormdragon2976
d08a335846 Added game Danger City. 2022-12-04 17:08:38 -05:00
stormdragon2976
1d512ff129 make sure nvda2speechd is available for bk3. 2022-11-29 09:09:48 -05:00
stormdragon2976
307c45766c Added noconfirm to install options for yay 2022-11-29 00:01:46 -05:00
Storm Dragon
560b07c18f Apply swamp patch in installation so you get the correct version. 2022-11-25 11:21:11 -05:00
Storm Dragon
5f3445ca96 Move the installer script from the fossil repository into here, under the wine directory. 2022-11-25 10:55:22 -05:00
Storm Dragon
433b195ba5 Updated install_nvda.sh to use the internal winetricks. 2022-11-22 14:22:07 -05:00
Storm Dragon
39bd8b4f62 Finally got Dragon Pong working. 2022-11-15 22:24:23 -05:00
Storm Dragon
728b24f9b4 Quick script to install nvda, specify bottle as argument, default is nvda. 2022-11-15 14:35:49 -05:00
Storm Dragon
7d7a3108dd 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. 2022-11-14 08:07:30 -05:00
Storm Dragon
2f92150c10 Added translate-shell to the -c flag. 2022-11-11 16:09:38 -05:00
Storm Dragon
f986d5605a RS Games is finiky on some computers, attempted fix. 2022-11-10 20:09:23 -05:00
7 changed files with 307 additions and 119 deletions

View File

@ -69,7 +69,7 @@ check_news() {
# Automatic update function # Automatic update function
update() { update() {
local url="$(git ls-remote --get-url)" local url="$(git ls-remote --get-url)"
if [[ "$url" =~ ^ssh://|git@ ]] || [[ -z "$url" ]]; then if [[ "$url" =~ ^ssh://|git@|gitea@ ]] || [[ -z "$url" ]]; then
return return
fi fi
git remote update &> /dev/null git remote update &> /dev/null
@ -130,62 +130,6 @@ desktop_launcher() {
exit 0 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 # Wine configuration section
@ -252,6 +196,24 @@ checklist() {
errorList+=("Warning: Sox is not installed. Audio will not work.") errorList+=("Warning: Sox is not installed. Audio will not work.")
fi fi
packageList+=("sox") 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 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 if command -v unix2dos &> /dev/null ; then
[[ $# -eq 0 ]] && echo "Dos2unix is installed." [[ $# -eq 0 ]] && echo "Dos2unix is installed."
else else
@ -436,6 +398,7 @@ help() {
echo "The syntax is variable=\"value\"" echo "The syntax is variable=\"value\""
echo echo
echo "noCache=\"true\" # Do not keep downloaded items in the cache." 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 "norh=\"true\" # Do not install RHVoice."
echo "redownload=\"true\" # Redownload sources, do not use the version stored in cache." echo "redownload=\"true\" # Redownload sources, do not use the version stored in cache."
echo "rhvoice=\"voicename\" # Select the voice to be installed (default Bdl)." echo "rhvoice=\"voicename\" # Select the voice to be installed (default Bdl)."
@ -578,7 +541,7 @@ install_wine_bottle() {
{ DISPLAY="" wineboot -u { DISPLAY="" wineboot -u
wine msiexec /i z:"$monoPath" /quiet wine msiexec /i z:"$monoPath" /quiet
wine msiexec /i z:"$geckoPath" /quiet wine msiexec /i z:"$geckoPath" /quiet
if [[ "${*}" =~ speechsdk ]]; then if [[ "${*}" =~ (speechsdk|sapi) ]]; then
install_rhvoice install_rhvoice
fi fi
if [[ "${WINEARCH}" == "win64" ]]; then if [[ "${WINEARCH}" == "win64" ]]; then
@ -769,25 +732,37 @@ game_launcher() {
if command -v qjoypad &> /dev/null ; then if command -v qjoypad &> /dev/null ; then
mkdir -p ~/.qjoypad3 mkdir -p ~/.qjoypad3
touch "${HOME}/.qjoypad3/${game%|*}.lyt" touch "${HOME}/.qjoypad3/${game%|*}.lyt"
if [[ "${noqjoypad}" != "true" ]]; then
if pgrep qjoypad &> /dev/null ; then if pgrep qjoypad &> /dev/null ; then
qjoypad -T "${game%|*}" 2> /dev/null qjoypad -T "${game%|*}" 2> /dev/null
else else
qjoypad -T "${game%|*}" 2> /dev/null & qjoypad -T "${game%|*}" 2> /dev/null &
fi fi
fi fi
fi
# for games that require custom scripts before launch or custom launch parameters # 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 if [[ "$game" =~ haunted-party ]]; then
pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd & pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd &
fi fi
if [[ "$game" =~ laser-breakout ]]; then if [[ "$game" =~ laser-breakout ]]; then
pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd & pgrep -u "$USER" nvda2speechd &> /dev/null || ${XDG_DATA_HOME:-$HOME/.local/share}/audiogame-manager/nvda2speechd &
fi fi
if [[ "$game" =~ ^bokurano-daibouken\||bokurano-daibouken-2\| ]]; then if [[ "$game" =~ ^bokurano-daibouken-2\| ]]; then
"${0%/*}/speech/clipboard_translator.sh" play.exe & "${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 fi
if [[ "$game" =~ shadow-line ]]; then if [[ "$game" =~ shadow-line ]]; then
find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \; 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 fi
if [[ "$game" =~ bokurano-daibouken-3 ]]; then if [[ "$game" =~ bokurano-daibouken-3 ]]; then
dictPath="$(winepath "${winePath}")" dictPath="$(winepath "${winePath}")"
@ -802,7 +777,7 @@ game_launcher() {
fi fi
if [[ ! -d "${dictPath}/dict" ]] && [[ ! -r "${cache}/bk3-dict.dat" ]]; then if [[ ! -d "${dictPath}/dict" ]] && [[ ! -r "${cache}/bk3-dict.dat" ]]; then
find "${WINEPREFIX}/drive_c/nyanchangame/bk3" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \; 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
fi fi
if [[ "$game" =~ bop-it-emulator ]]; then if [[ "$game" =~ bop-it-emulator ]]; then
@ -815,7 +790,7 @@ game_launcher() {
"${0%/*}/speech/speak_window_title.sh" trtr.exe & "${0%/*}/speech/speak_window_title.sh" trtr.exe &
fi fi
if [[ "$game" =~ sequence-storm ]]; then if [[ "$game" =~ sequence-storm ]]; then
[[ -x ~/.SequenceStormReader ]] && ~/.SequenceStormReader & "${0%/*}/speech/clipboard_reader.sh" SequenceStorm &
fi fi
if [[ "$game" =~ audiodisc ]]; then if [[ "$game" =~ audiodisc ]]; then
wine "$winePath\\$wineExec" wine "$winePath\\$wineExec"
@ -825,7 +800,7 @@ game_launcher() {
wine "$winePath\\$wineExec" wine "$winePath\\$wineExec"
exit 0 exit 0
fi fi
if [[ "$game" =~ screaming-strike-2 ]]; then if [[ "$game" =~ rs-games ]] || [[ "$game" =~ screaming-strike-2 ]]; then
pushd "$(winepath "$winePath")" pushd "$(winepath "$winePath")"
wine "$wineExec" wine "$wineExec"
popd popd
@ -997,13 +972,14 @@ gameList=(
"Crazy Party" "Crazy Party"
"Crazy Tennis" "Crazy Tennis"
"Crime Hunter" "Crime Hunter"
"Danger City"
"Danger on the Wheel" "Danger on the Wheel"
#"Dark Destroyer" #"Dark Destroyer"
"Daytona and the Book of Gold" "Daytona and the Book of Gold"
"Death on the Road" "Death on the Road"
"Deathmatch" "Deathmatch"
"Dog Who Hates Toast" "Dog Who Hates Toast"
#"Dragon Pong" "Dragon Pong"
"Duck Hunt" "Duck Hunt"
"DynaMan" "DynaMan"
"Easter Quest" "Easter Quest"
@ -1091,7 +1067,7 @@ gameList=(
"The Vale" "The Vale"
"Thief" "Thief"
"Traders of Known Space" "Traders of Known Space"
#"Three D velocity" "Three D velocity"
"Tomb Hunter" "Tomb Hunter"
"Top Speed 2" "Top Speed 2"
"Top Speed 3" "Top Speed 3"
@ -1135,6 +1111,7 @@ declare -A command=(
[N]="No cache, delete the installer after it has been extracted." [N]="No cache, delete the installer after it has been extracted."
[n]="No RHVoice, do not install RHVoice when the game is installed." [n]="No RHVoice, do not install RHVoice when the game is installed."
[P]="Print a list of packages required by audiogame-manager." [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]="Redownload. Removes old versions of packages from cache before installing."
[r]="Remove a game. This will delete all game data." [r]="Remove a game. This will delete all game data."
[t]="Total games. Show how many games are currently available." [t]="Total games. Show how many games are currently available."
@ -1164,6 +1141,9 @@ while getopts "${args}" i ; do
N) noCache="true";; N) noCache="true";;
n) norh="true";; n) norh="true";;
P) checklist quiet;; P) checklist quiet;;
q)
noqjoypad="true"
game_launcher;;
R) redownload="true";; R) redownload="true";;
r) game_removal;; r) game_removal;;
t) t)
@ -1670,7 +1650,9 @@ case "${game}" in
export bottle="nyanchan" export bottle="nyanchan"
export winVer="win7" export winVer="win7"
install_wine_bottle 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" 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" "{}" \; find "${WINEPREFIX}" -type f -name 'nvdaControllerClient.dll' -exec cp -v "${cache}/nvda2speechd32.dll" "{}" \;
add_launcher "c:\nyanchangame\bk3\play.exe" add_launcher "c:\nyanchangame\bk3\play.exe"
@ -1818,6 +1800,17 @@ case "${game}" in
find "${WINEPREFIX}" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \; find "${WINEPREFIX}" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \;
add_launcher "c:\Program Files\crime-hunter\ch.exe" 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") "Danger on the Wheel")
export bottle="oriol-gomez" export bottle="oriol-gomez"
export winVer="win7" export winVer="win7"
@ -1872,7 +1865,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 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") "Dragon Pong")
install_wine_bottle vb6run dx8vb speechsdk export winVer="win7"
install_wine_bottle
download "https://www.iamtalon.me/games/dragonpong.zip" download "https://www.iamtalon.me/games/dragonpong.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/dragonpong.zip" unzip -d "$WINEPREFIX/drive_c/Program Files" "${cache}/dragonpong.zip"
add_launcher "c:\Program Files\dragonpong\DragonPong.exe" add_launcher "c:\Program Files\dragonpong\DragonPong.exe"
@ -2631,9 +2625,9 @@ EOF
download "https://www.kaldobsky.com/audiogames/Swamp.zip" download "https://www.kaldobsky.com/audiogames/Swamp.zip"
unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/Swamp.zip" unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/Swamp.zip"
# make sure the latest version is installed. # make sure the latest version is installed.
#if wget -O "${cache}/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then 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" unzip -o -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/SwampPatch.zip"
#fi fi
wine 'c:\Program Files\swamp\checkup.exe' /verysilent wine 'c:\Program Files\swamp\checkup.exe' /verysilent
#wine cmd.exe /c 'cd /d c:\Program Files\swamp && Windows32bit.bat' #wine cmd.exe /c 'cd /d c:\Program Files\swamp && Windows32bit.bat'
# Delete music if requested. # Delete music if requested.
@ -2732,13 +2726,16 @@ EOF
;; ;;
"Three D velocity") "Three D velocity")
export winVer="win10" export winVer="win10"
install_wine_bottle speechsdk 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. # Dotnet is evil. That is all.
LC_ALL=C winetricks -q dotnet472 # LC_ALL=C winetricks -q dotnet48
wineserver -k # Ha ha ha. # wineserver -k # Ha ha ha.
download "https://github.com/munawarb/Three-D-Velocity-Binaries/archive/master.zip" "https://stormgames.wolfe.casa/downloads/nvdaControllerClient32.dll" 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" 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" add_launcher "c:\Program Files\Three-D-Velocity-Binaries-master\tdv.exe"
;; ;;
"Triple Triad") "Triple Triad")

47
speech/clipboard_reader.sh Executable file
View File

@ -0,0 +1,47 @@
#!/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
sleep 0.05
if [[ -f ~/.agmsilent ]]; then
continue
fi
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
done
exit 0

View File

@ -1,20 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
cleanup() { # Modified from the script at:
sort -uo "$dictionaryFile" "$dictionaryFile" # 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 if [[ $# -ne 2 ]]; then
echo "Usage: $0 application name." echo "Usage: $0 \"application name\" \"file name\"."
exit 1
fi fi
# Wait for the application to start # Wait for the application to start
@ -22,33 +17,66 @@ while ! pgrep -u "$USER" ^$1 &> /dev/null ; do
sleep 0.05 sleep 0.05
done done
fileName="${2,,}"
fileName="${fileName//[[:space:]]/-}.sqlite"
translationFile="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/${fileName}"
# Read so long as the application is running # Read so long as the application is running
while pgrep -u "$USER" ^$1 &> /dev/null ; do while pgrep -u "$USER" ^$1 &> /dev/null ; do
newText="" sleep 0.05
translatedText="" text="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)"
newText="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)" if [[ -f ~/.agmsilent ]]; then
sleep 0.01
if [[ "${#newText}" -lt 1 ]]; then
continue continue
fi fi
if [[ "${newText}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then if [[ "${text}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then
spd-say -- "$newText" spd-say -- "$text"
echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null
continue continue
fi fi
export newText if [[ -z "$text" ]]; then
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
continue continue
fi fi
translatedText="$(trans -no-autocorrect -b -- "$newText")" q() { sqlite3 -column -init "" "$translationFile" "$@" 2> /dev/null ; }
if ! [[ "${newText}" =~ ^[0-9[:punct:]]+$ ]]; then
echo "${newText})==:[${translatedText}" >> "$dictionaryFile"
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 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 echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null
done done
exit 0

11
speech/install_nvda.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
export DISPLAY=${DISPLAY:-:0}
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
[[ -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

View File

@ -113,12 +113,12 @@ menulist() {
for i in "${@}" ; do for i in "${@}" ; do
menuList+=("$i" "$i") menuList+=("$i" "$i")
done 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 \ --clear \
--extra-button \ --extra-button \
--extra-label "$(gettext "Test Voice")" \ --extra-label "Test Voice" \
--no-tags \ --no-tags \
--menu "$(gettext "Please select one")" 0 0 0 "${menuList[@]}" --stdout --menu "Please select one" 0 0 0 "${menuList[@]}" --stdout
return $? return $?
} }
@ -163,12 +163,12 @@ test_voice() {
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 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" $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 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 "z:\tmp\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
@ -176,12 +176,12 @@ doRestore=1
trap restore_voice SIGINT 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. # 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 dim speechobject
set speechobject=createobject("sapi.spvoice") set speechobject=createobject("sapi.spvoice")
speechobject.speak "" speechobject.speak ""
EOF EOF
wine cscript "z:\tmp\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"
@ -194,7 +194,7 @@ for x in "${voiceListFullName[@]}" ; do
done 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')" 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 exit=1
if [[ "${voiceList[@]}" -eq 0 ]]; then if [[ "${#voiceList[@]}" -eq 0 ]]; then
dialog --msgbox "No voices found." -1 -1 dialog --msgbox "No voices found." -1 -1
exit 1 exit 1
fi fi

View File

@ -9,6 +9,10 @@ done
# Read so long as the application is running # Read so long as the application is running
while pgrep -u "$USER" ^$1 &> /dev/null ; do while pgrep -u "$USER" ^$1 &> /dev/null ; do
sleep 0.05
if [[ -f ~/.agmsilent ]]; then
continue
fi
wnd_focus=$(xdotool getwindowfocus) wnd_focus=$(xdotool getwindowfocus)
wnd_title=$(xprop -id $wnd_focus WM_NAME) wnd_title=$(xprop -id $wnd_focus WM_NAME)
lookfor='"(.*)"' lookfor='"(.*)"'
@ -20,5 +24,6 @@ while pgrep -u "$USER" ^$1 &> /dev/null ; do
old_title="$wnd_title" old_title="$wnd_title"
fi fi
fi fi
sleep 0.01
done done
exit 0

100
wine/install-dependencies.sh Executable file
View File

@ -0,0 +1,100 @@
#!/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
translate-shell
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 --noconfirm $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