Lots of changes to get Mac support working.Merge branch 'testing'

This commit is contained in:
Storm Dragon 2020-12-13 12:25:44 -05:00
commit a3d5fd5b6a
2 changed files with 114 additions and 48 deletions

View File

@ -1,4 +1,22 @@
#!/bin/bash #!/usr/bin/env bash
#
# Copyright 2020, Stormux, <storm_dragon@linux-a11y.org>
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Dialog accessibility # Dialog accessibility
export DIALOGOPTS='--no-lines --visit-items' export DIALOGOPTS='--no-lines --visit-items'
@ -28,6 +46,15 @@ update() {
fi fi
} }
# Function to open urls across OS.
open_url() {
if [[ "$(uname)" == "Darwin" ]]; then
open "${*}"
else
xdg-open "${*}"
fi
}
# Create the clipboard reading function for Sequence Storm # Create the clipboard reading function for Sequence Storm
write_sequence_storm_reader() { write_sequence_storm_reader() {
if -e ~/.SequenceStormReader ]]; then if -e ~/.SequenceStormReader ]]; then
@ -35,7 +62,7 @@ write_sequence_storm_reader() {
fi fi
# Here-document start # Here-document start
cat << "EOF" > ~/.SequenceStormReader cat << "EOF" > ~/.SequenceStormReader
#! /bin/bash #!/usr/bin/env bash
# Wait for the game to be launched # Wait for the game to be launched
while ! pgrep -u $USER ^SequenceStorm &> /dev/null ; do while ! pgrep -u $USER ^SequenceStorm &> /dev/null ; do
@ -45,16 +72,28 @@ done
export DISPLAY=:0 export DISPLAY=:0
unset cliptext unset cliptext
while pgrep -u $USER ^SequenceStorm &> /dev/null ; do 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)" tmp="$(xclip -selection clipboard -o 2> /dev/null)"
fi
tmp="${tmp//%/ percent }" tmp="${tmp//%/ percent }"
if [ "$tmp" != "$cliptext" ] ; then if [ "$tmp" != "$cliptext" ] ; then
cliptext="$tmp" cliptext="$tmp"
if [[ "${cliptext,,}" =~ key|load|private|says|terminal ]]; then if [[ "${cliptext,,}" =~ key|load|private|says|terminal ]]; then
if [[ "$(uname)" == "Darwin" ]]; then
say -v alex -r 300 "$cliptext"
else
spd-say -w -r 50 -- "$cliptext" spd-say -w -r 50 -- "$cliptext"
fi
else
if [[ "$(uname)" == "Darwin" ]]; then
say -v alex -r 300 "$cliptext"
else else
spd-say -r 50 -- "$cliptext" spd-say -r 50 -- "$cliptext"
fi fi
fi fi
fi
sleep 0.05 sleep 0.05
done done
@ -163,7 +202,7 @@ help() {
echo -e "Usage:\n" echo -e "Usage:\n"
echo "With no arguments, open the game launcher." echo "With no arguments, open the game launcher."
for i in "${!command[@]}" ; do for i in "${!command[@]}" ; do
echo "-${i}: ${command[${i}]}" echo "-${i/:/ <parameter>}: ${command[${i}]}"
done | sort done | sort
exit 0 exit 0
} }
@ -231,11 +270,11 @@ game_removal() {
--menu "Please select a game to delete" 0 0 0 "${menuList[@]}" --stdout)" --menu "Please select a game to delete" 0 0 0 "${menuList[@]}" --stdout)"
if [[ ${#game} -gt 0 ]]; then if [[ ${#game} -gt 0 ]]; then
if [[ "$game" == "Make a One Time Donation" ]]; then if [[ "$game" == "Make a One Time Donation" ]]; then
xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" open_url "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted"
exit 0 exit 0
fi fi
if [[ "$game" == "Become a Patron" ]]; then if [[ "$game" == "Become a Patron" ]]; then
xdg-open "https://patreon.com/stormux" open_url "https://patreon.com/stormux"
exit 0 exit 0
fi fi
local winePath="${game#*|}" local winePath="${game#*|}"
@ -261,6 +300,7 @@ game_launcher() {
echo "Install some games first." echo "Install some games first."
exit 0 exit 0
fi fi
if [[ $# -eq 0 ]]; then
# Create the menu of installed games # Create the menu of installed games
declare -a menuList declare -a menuList
for i in "${lines[@]}" ; do for i in "${lines[@]}" ; do
@ -272,13 +312,21 @@ game_launcher() {
--clear \ --clear \
--no-tags \ --no-tags \
--menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)" --menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)"
else
local game="$(grep "^${1}|" "${configFile}")"
game="${game%|*}"
if [[ -z "$game" ]]; then
echo "Game $1 not found."
exit 1
fi
fi
if [[ ${#game} -gt 0 ]]; then if [[ ${#game} -gt 0 ]]; then
if [[ "$game" == "Make a One Time Donation" ]]; then if [[ "$game" == "Make a One Time Donation" ]]; then
xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" open_url "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted"
exit 0 exit 0
fi fi
if [[ "$game" == "Become a Patron" ]]; then if [[ "$game" == "Become a Patron" ]]; then
xdg-open "https://patreon.com/stormux" open_url "https://patreon.com/stormux"
exit 0 exit 0
fi fi
# for games that require custom scripts before launch # for games that require custom scripts before launch
@ -333,23 +381,6 @@ add_launcher() {
fi fi
} }
automate_installer() {
# Function arguments are the keys to be pressed.
sleep 15
declare -a keyList
for i in ${@} ; do
case "$i" in
"alt+f") keyList+=("sleep 15 key ${i}");;
"space") keyList+=("sleep 1 key ${i}");;
*"+"*) keyList+=("sleep 1 key ${i}");;
*) xdotool sleep 1 type ${i};;
esac
done
xdotool ${keyList[*]} &
# call wineserver -w in case something failed here, the user will have a chance to try to fix it.
wineserver -w
}
# Check for updates # Check for updates
update update
# If display isn't set assume we are launching from console and an X environment is running using display :0 # If display isn't set assume we are launching from console and an X environment is running using display :0
@ -383,6 +414,7 @@ gameList=(
#"Chopper Challenge" #"Chopper Challenge"
"Christmas WhoopAss" "Christmas WhoopAss"
"Crazy Party" "Crazy Party"
"Crazy Tennis"
"Death on the Road" "Death on the Road"
"Easter Quest" "Easter Quest"
#"Entombed" #"Entombed"
@ -432,9 +464,10 @@ fi
# Array of command line arguments # Array of command line arguments
declare -A command=( declare -A command=(
[c]="Check your system for necessary components." [c]="Check your system for necessary components."
[d]="debug mode, wine will be much more verbose when games are launched with this flag."
[h]="This help screen." [h]="This help screen."
[i]="Install games." [i]="Install games."
[m]="Manually handle install screens instead of using xdotools." [l:]="launch given game without interactive audiogame-manager menu specified by its wine bottle."
[N]="No cache, delete the installer after it has been extracted." [N]="No cache, delete the installer after it has been extracted."
[r]="Remove a game. This will delete all game data." [r]="Remove a game. This will delete all game data."
) )
@ -445,9 +478,13 @@ args="${args//[[:space:]]/}"
while getopts "${args}" i ; do while getopts "${args}" i ; do
case "$i" in case "$i" in
c) checklist;; c) checklist;;
d)
unset WINEDEBUG
game_launcher
;;
h) help;; h) help;;
i) game_installer;; i) game_installer;;
m) manualInstall="true";; l) game_launcher "${OPTARG}";;
N) noCache="true";; N) noCache="true";;
r) game_removal;; r) game_removal;;
esac esac
@ -523,6 +560,14 @@ case "${game}" in
add_launcher "c:\Program Files\Crazy-Party-beta73\Crazy Party.exe" add_launcher "c:\Program Files\Crazy-Party-beta73\Crazy Party.exe"
rm -f "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta73/nvdaControllerClient32.dll" rm -f "${WINEPREFIX}/drive_c/Program Files/Crazy-Party-beta73/nvdaControllerClient32.dll"
;; ;;
"Crazy Tennis")
install_wine_bottle speechsdk
download "https://www.agarchive.net/games/VIP/crazy%20tennis%20setup.exe"
wine "${cache}/crazy tennis setup.exe" /silent &
xdotool sleep 10 key --clearmodifiers alt+y 2> /dev/null
wineserver -w
add_launcher "c:\Program Files\Crazytennis\crazytennis.exe"
;;
"Death on the Road") "Death on the Road")
export winVer="win7" export winVer="win7"
install_wine_bottle install_wine_bottle
@ -890,10 +935,10 @@ EOF
add_launcher "c:\Program Files\undead_assault\Undead Assault.exe" add_launcher "c:\Program Files\undead_assault\Undead Assault.exe"
;; ;;
"Make a One Time Donation") "Make a One Time Donation")
xdg-open "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted" open_url "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=stormdragon2976@gmail.com&lc=US&item_name=Donation+to+Storm+Games&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted"
;; ;;
"Become a Patron") "Become a Patron")
xdg-open "https://patreon.com/stormux" open_url "https://patreon.com/stormux"
;; ;;
*) *)
exit 0 exit 0

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# Set Voice # Set Voice
# Set the default wine voice based on installed options. # Set the default wine voice based on installed options.
# Rate can be specified as a numeric argument to this script, 1 through 9. # Rate can be specified as a numeric argument to this script, 1 through 9.
@ -91,8 +91,12 @@ menulist() {
restore_voice() { restore_voice() {
if [[ $doRestore -eq 0 ]]; then if [[ $doRestore -eq 0 ]]; then
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
if [[ "$(uname)" == "Darwin" ]]; then
gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
else
sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="'"${oldVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
fi fi
fi
} }
set_voice() { set_voice() {
@ -107,8 +111,13 @@ set_voice() {
fullVoice="${voiceListFullName[$counter]}" fullVoice="${voiceListFullName[$counter]}"
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
# Remove any existing rate change for voices # Remove any existing rate change for voices
if [[ "$(uname)" == "Darwin" ]]; then
gsed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg"
gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg"
else
sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg" sed -i '/"DefaultTTSRate"=dword:/d' "${WINEPREFIX}/user.reg"
sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg" sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"\n"DefaultTTSRate"=dword:0000000'${2:-7}'/g' "${WINEPREFIX}/user.reg"
fi
} }
test_voice() { test_voice() {
@ -122,7 +131,11 @@ test_voice() {
done done
fullVoice="${voiceListFullName[$counter]}" fullVoice="${voiceListFullName[$counter]}"
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
if [[ "$(uname)" == "Darwin" ]]; then
gsed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
else
sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg" sed -i -E -e 's/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"/"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\'"${fullVoice//\\/\\\\}"'"/g' "${WINEPREFIX}/user.reg"
fi
cat << "EOF" > /tmp/speak.vbs cat << "EOF" > /tmp/speak.vbs
dim speechobject dim speechobject
set speechobject=createobject("sapi.spvoice") set speechobject=createobject("sapi.spvoice")
@ -138,13 +151,21 @@ trap restore_voice SIGINT
# Create an array of available voices. # Create an array of available voices.
ifs="$IFS" ifs="$IFS"
IFS=$'\n' IFS=$'\n'
voiceListFullName=($(grep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | sed -E -e 's/\[([^]]+)\].*/\1/g')) if [[ "$(uname)" == "Darwin" ]]; then
voiceListFullName=($(ggrep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | sed -E -e 's/\[([^]]+)\].*/\1/g'))
else
voiceListFullName=($(grep -P '\[Software\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^\\]+\].*' "${WINEPREFIX}/system.reg" | sed -E -e 's/\[([^]]+)\].*/\1/g'))
fi
IFS="$ifs" IFS="$ifs"
voiceList=() voiceList=()
for x in "${voiceListFullName[@]}" ; do for x in "${voiceListFullName[@]}" ; do
voiceList+=("$(echo "$x" | rev | cut -d\\ -f1 | rev)") voiceList+=("$(echo "$x" | rev | cut -d\\ -f1 | rev)")
done done
oldVoice="$(grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')" if [[ "$(uname)" == "Darwin" ]]; then
oldVoice="$(ggrep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
else
oldVoice="$(grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Tokens\\\\[^"]+"' "${WINEPREFIX}/user.reg" | sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
fi
echo "oldVoice: ${oldVoice}" echo "oldVoice: ${oldVoice}"
echo "voiceList: ${voiceList[@]}" echo "voiceList: ${voiceList[@]}"
echo "voiceListFullName: ${voiceListFullName[@]}" echo "voiceListFullName: ${voiceListFullName[@]}"