Compare commits

...

93 Commits

Author SHA1 Message Date
Storm Dragon
623de671f2 Merge branch 'testing' latest changes. Huge refactor on the way, it may be best to use this branch until further notice. 2025-05-18 16:41:18 -04:00
Storm Dragon
d6cfe797bc Latest changes before huge refactor. 2025-05-18 16:39:58 -04:00
Storm Dragon
50b577d7aa Make sure variables needed for installation scripts are exported. 2025-05-14 13:58:16 -04:00
Storm Dragon
ef43dca94f Updated the clipboard translater because it could crash on some translations. 2025-05-14 04:36:30 -04:00
Storm Dragon
a38fc607a8 Updated download link for "Challenge of the Horse". 2025-05-08 23:39:52 -04:00
937b52ffd0 Added tiny game smashathon. Get angry! 2025-05-02 01:22:50 -07:00
4ee362b1c0 Added game constant motion. This is temporary until sam releases a linux version. 2025-05-01 04:17:32 -07:00
Storm Dragon
f86d25924f links for rhvoice updated. 2025-04-16 00:09:49 -04:00
Storm Dragon
6dbf578c5a Fixed a problem with the file name for BG Cricket. 2025-02-07 21:27:19 -05:00
Storm Dragon
ec8bb229f0 Actually close audiogame-manager if escape is pressed instead of trying, and failing, to launch the game. 2025-01-23 16:20:03 -05:00
Storm Dragon
3d95cefb02 Updated Mist World installer for Wine 10.0. Now requires sapi. 2025-01-23 15:47:47 -05:00
Storm Dragon
d9c6c80e00 Updated Swamp for wine 10.0. Removed ole32 dependency as it was causing it to fail. If you are on wine 9.0 run WINEPREFIX=~/.local/wine/aprone winetricks -q ole32 If you have problems. 2025-01-23 15:16:41 -05:00
Storm Dragon
8b8f01f39d Temporary work around for winetricks problems. Be sure to install winetricks with your package manager. 2025-01-20 17:55:23 -05:00
a18b2ec61b Shades 2.0 now works as well 2025-01-19 13:33:58 -08:00
e6cfa00c15 Shades of doom 1.2 is working for me on wine 9.22 2025-01-18 19:18:58 -08:00
Storm Dragon
0a1a130399 Fixed a bug with the default download check. 2025-01-17 17:36:40 -05:00
Storm Dragon
a8833aa173 Merge branch 'testing' of git.stormux.org:storm/audiogame-manager into testing 2025-01-16 13:30:53 -05:00
Storm Dragon
447344bec9 Fixed an error with finding wine_gecko. 2025-01-16 13:30:40 -05:00
Storm Dragon
ba0844cc49 Merge branch 'testing' games added. 2024-12-12 19:02:28 -05:00
Storm Dragon
9a47da3239 Merge branch 'testing' latest game additions, updates, and bug fixes. 2024-11-26 00:31:34 -05:00
Storm Dragon
2c8b419656 Merge branch 'testing' latest games and updates. 2024-04-05 19:54:23 -04:00
Storm Dragon
06c50154fc Merge branch 'testing' latest games and code with new IPFS support. 2024-02-29 04:30:03 -05:00
Storm Dragon
8b3e1b777b Merge branch 'testing' latest game additions. 2023-08-07 20:45:44 -04:00
stormdragon2976
e9b23e968f Merge branch 'testing', latest code and games. 2023-06-12 15:21:03 -04:00
stormdragon2976
54e3ef8190 Merge branch 'testing', latest games. 2023-04-05 22:42:29 -04:00
stormdragon2976
2472ea640a Merge branch 'testing' latest fixes and instructions. 2023-03-16 16:52:38 -04:00
stormdragon2976
43005a75b6 Merge branch 'testing' introduces game specific wine versions. Breaks
Mac compatibility. Please see the wiki for an alternative option.
2023-03-02 00:58:18 -05:00
stormdragon2976
7359be180b Latest version of README merged to master. 2023-02-10 09:47:05 -05:00
stormdragon2976
fbba315e1b Merge branch 'testing', latest stable code and new games. 2023-01-23 16:19:44 -05:00
stormdragon2976
6b69da95c0 Merge branch 'testing', latest code and bug fixes. 2023-01-03 19:09:26 -05:00
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
Storm Dragon
50bb4a5383 Merge branch 'testing' latest code and bug fixes. 2022-11-10 18:16:48 -05:00
Storm Dragon
c5d88f5215 Merge branch 'testing' latest games and fixes. 2022-10-30 14:46:35 -04:00
Storm Dragon
8b7704167a Merge branch 'testing' latest games and bug fixes. 2022-10-23 19:08:01 -04:00
Storm Dragon
f2cdcaa62a Merge branch 'testing' latest bug fixes. 2022-10-15 18:08:50 -04:00
Storm Dragon
7bd0bb60f4 Merge branch 'testing' updated the README. 2022-10-06 16:46:44 -04:00
Storm Dragon
30803d6066 Merge branch 'testing' forgot to make a change to an installation file
before last merge.
2022-10-06 15:30:47 -04:00
Storm Dragon
90d64278aa Merge branch 'testing'. Things appear to be decently stable now. 2022-10-06 11:56:27 -04:00
Storm Dragon
620b8af135 Merge branch 'testing' 2022-09-19 11:14:10 -04:00
Storm Dragon
e86ddd7935 Merge branch 'testing' latest Crazy Party, beta 78. 2022-08-20 23:06:41 -04:00
Storm Dragon
4cce555b7d Merge branch 'testing' new changes are coming in testing that may cause
instability so checkpointing while it's stable.
2022-08-20 12:24:07 -04:00
Storm Dragon
fa75ba31ca Merge branch 'testing'. This marks the end of binary releases. Everyone
should now be using from git. The binary downloads have been removed.
2022-05-13 13:31:34 -04:00
Storm Dragon
11139ce376 Merge branch 'testing' in preparation for binary release. 2022-03-06 22:36:10 -05:00
Storm Dragon
10f4871bee Merge branch 'testing' in preparation for binary release. 2022-02-24 10:35:14 -05:00
Storm Dragon
ace9f56ae9 Merge branch 'testing' in preparation for binary release. 2022-02-06 14:36:21 -05:00
Storm Dragon
b290387fa0 Merge branch 'testing' in preparation for binary release. 2022-01-15 00:28:42 -05:00
Storm Dragon
2b436df45d Merge branch 'testing' in preparation for binary release. 2021-12-22 11:40:31 -05:00
Storm Dragon
e091ff036b Merge branch 'testing' in preparation for binary release. 2021-10-24 09:37:39 -04:00
Storm Dragon
4975822ce1 Merge branch 'testing' in preparation for binary release. 2021-09-11 23:54:41 -04:00
Storm Dragon
e0d9a9564d Merge branch 'testing' in preparation for binary release. 2021-08-20 16:58:43 -04:00
Storm Dragon
226c080cd0 Merge branch 'testing' in preparation for binary release. 2021-08-09 00:36:20 -04:00
Storm Dragon
6daad63de4 Merge branch 'testing' in preparation for binary release. 2021-07-23 18:55:45 -04:00
Storm Dragon
e133f7d318 Merge branch 'testing' in preparation for binary release. 2021-07-10 13:38:32 -04:00
Storm Dragon
fe8135ba96 Merge branch 'testing' in preparation for binary release. 2021-07-02 18:58:55 -04:00
Storm Dragon
054d0b2d5e Merge branch 'testing' in preparation for binary release. 2021-06-26 01:50:52 -04:00
Storm Dragon
7b57f8c8d2 Merge branch 'testing' in preparation for binary release. 2021-06-02 21:27:26 -04:00
Storm Dragon
f5b8b26c01 Merge branch 'testing' in preparation for binary release. 2021-05-10 18:01:42 -04:00
Storm Dragon
250498706d Merge branch 'testing' in preparation for binary release. 2021-05-04 12:08:09 -04:00
Storm Dragon
6b9428d2e4 Merge branch 'testing' in preparation for new binary release. 2021-04-28 18:09:25 -04:00
Storm Dragon
18a30297e8 Merge branch 'testing' in preparation for new binary release. 2021-04-27 02:43:04 -04:00
Storm Dragon
4f206e13cc Merge branch 'testing' in preparation for new binary release. 2021-04-24 15:51:56 -04:00
Storm Dragon
6cfdf58e68 Merge branch 'testing' for new binary release. 2021-02-28 14:01:57 -05:00
Storm Dragon
f7623868fc Merge branch 'testing' for new binary release 2021-02-21 17:41:20 -05:00
Storm Dragon
8ff0a56874 Merged to master for new release. 2021-01-16 23:36:07 -05:00
Storm Dragon
4cb854b881 Merge branch 'testing' 2021-01-10 12:47:36 -05:00
Storm Dragon
7052aefbb0 merged the Crazy Party update script to master. 2020-12-22 18:07:32 -05:00
Storm Dragon
fcce6243bf Merged to master. 2020-12-22 11:21:04 -05:00
Storm Dragon
bdeef5b367 Merged to master. 2020-12-20 22:19:26 -05:00
Storm Dragon
017f823544 merged to master. 2020-12-17 09:36:20 -05:00
Storm Dragon
1759661f34 removed duplicate file. 2020-12-13 12:27:24 -05:00
Storm Dragon
a3d5fd5b6a Lots of changes to get Mac support working.Merge branch 'testing' 2020-12-13 12:25:44 -05:00
Storm Dragon
61cf058921 Merged to master. 2020-12-06 12:47:43 -05:00
Storm Dragon
78a037a6b1 Removed install-wine.sh because that project has moved to https://fossil.wolfe.casa/install-audiogame-manager 2020-12-06 12:35:42 -05:00
Storm Dragon
6a4464d692 merged to master. 2020-12-06 12:34:23 -05:00
Storm Dragon
26e53ee2c3 merged to master. 2020-12-01 15:09:54 -05:00
Storm Dragon
8c2e37e135 Merged to master. 2020-11-28 21:31:50 -05:00
Storm Dragon
1bffc6f244 Merged to master. 2020-11-25 12:19:56 -05:00
Storm Dragon
38a64cdb64 Merged to master. 2020-11-24 19:19:44 -05:00
Storm Dragon
609edfe111 Merged to master. 2020-11-17 17:17:59 -05:00
Storm Dragon
881498ea47 merged to master. 2020-11-14 13:50:22 -05:00
Storm Dragon
9f42469b89 Merged to master. 2020-11-08 20:19:44 -05:00
Storm Dragon
8a17939f3c Fixed merge conflict. 2020-11-02 08:30:09 -05:00
Storm Dragon
b5fe20eb2d Latest stable release. 2020-10-26 19:04:54 -04:00
Storm Dragon
793efc694b Merged to master. 2020-10-18 09:21:13 -04:00
Storm Dragon
b7ff93c740 Added realtime flag to games when they launch. This hasn't shown any bad side affects, and may speed up games a bit. 2020-10-11 16:49:14 -04:00
Storm Dragon
fd33349864 Merged changes to master pending updated release. 2020-10-09 20:58:40 -04:00
Storm Dragon
e0b86e0e3c Merged a11y changes to master. 2020-09-29 22:08:10 -04:00
Storm Dragon
c3a7e39def Merged to master. 2020-09-21 06:59:28 -04:00
Storm Dragon
d9489819b7 Changed export for winearch to the installation function. 2020-09-21 06:56:31 -04:00
Storm Dragon
eae85b0299 Merged to master. 2020-09-20 17:43:18 -04:00
Storm Dragon
9532eef142 Merged latest audiogame-manager to master, added voice configuration utility. 2020-09-20 16:07:37 -04:00
Storm Dragon
14093c80ca Merged crazy pparty changes. 2020-09-20 11:23:03 -04:00
Storm Dragon
f46a4efa88 removed games that aren't working with speech. Started a new testing branch to try to get new games working before they are added to the released version. 2020-09-13 11:39:46 -04:00
14 changed files with 103 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
export bottle="bg"
download "${ipfsGateway}/ipfs/QmWAk2TMHMvW6Kjc1sZBEPsxmCNHfY3nF1K723PCqaTa57?filename=TPB32Setup10a.exe"
download "${ipfsGateway}/ipfs/QmWAk2TMHMvW6Kjc1sZBEPsxmCNHfY3nF1K723PCqaTa57?filename=T20B32Setup10.exe"
install_wine_bottle speechsdk
wine "${cache}/T20B32Setup10.exe" /silent
add_launcher "c:\Program Files\Games\T20CricketB\CricketB.exe"

View File

@@ -1,4 +1,4 @@
download "http://tunmi13.ddns.net/projects/bth.zip"
download "http://files.tunmi13.com/projects_archive/bth.zip"
export bottle="tunmi13"
export winVer="win7"
install_wine_bottle speechsdk

View File

@@ -1,4 +1,4 @@
download "http://tunmi13.ddns.net/projects/coth.zip"
download "http://files.tunmi13.com/projects_archive/coth.zip"
export bottle="tunmi13"
export winVer="win7"
install_wine_bottle speechsdk

View File

@@ -0,0 +1,7 @@
export WINEARCH=win64
export winVer="win7"
download "https://samtupy.com/games/cm.zip" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd64.dll"
install_wine_bottle
unzip -d "$WINEPREFIX/drive_c/Program Files/ConstantMotion" "$cache/cm.zip"
find "$WINEPREFIX/drive_c/Program Files/ConstantMotion" -name "nvdaControllerClient64.dll" -exec cp -v "$cache/nvda2speechd64.dll" "{}" \;
add_launcher 'c:\Program Files\ConstantMotion\cm.exe'

View File

@@ -1,7 +1,7 @@
export winVer="win7"
get_installer "Mist World_Setup.exe" "https://drive.google.com/uc?export=download&id=12YeUqorkkMT46ZSR5pcfWxSY8DHOLxZ-"
download "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd32.dll"
install_wine_bottle ole32
install_wine_bottle sapi
7z x -o"$WINEPREFIX/drive_c/Program Files/Mist World" "$cache/Mist World_Setup.exe"
sed -i 's/1024m/768m/g' "$WINEPREFIX/drive_c/Program Files/Mist World/mw.exe.vmoptions"
cp "$WINEPREFIX/drive_c/Program Files/Mist World/"{mw.exe.vmoptions,update.exe.vmoptions}

View File

@@ -1,4 +1,3 @@
#
download "http://gmagames.com/sod1208.exe"
install_wine_bottle vb6run dx8vb speechsdk
wine "${cache}/sod1208.exe" /sp- /verysilent

View File

@@ -1,5 +1,5 @@
export winVer="win7"
download "http://www.gmagames.com/sod20022.exe"
download "http://www.gmagames.com/sod20024.exe"
install_wine_bottle vb6run dx8vb speechsdk
wine "${cache}/sod20022.exe" /silent
wine "${cache}/sod20024.exe" /silent
add_launcher "c:\Program Files\Shades of Doom 2.0\sod.exe"

5
.install/Smashathon.sh Normal file
View File

@@ -0,0 +1,5 @@
export bottle="l-works"
download "https://agarchive.net/games/lworks/Smashathon0.02.zip"
install_wine_bottle speechsdk
unzip -d "$WINEPREFIX/drive_c/Program Files" "$cache/Smashathon0.02.zip"
add_launcher 'c:\Program Files\Smashathon0.02\smashathon.exe'

View File

@@ -1,5 +1,5 @@
export bottle="l-works"
download "http://files.l-works.net/superegghuntsetup.exe"
download "https://agarchive.net/games/lworks/super%20egg%20hunt+%20setup.exe"
install_wine_bottle
wine "${cache}/superegghuntsetup.exe" /silent
wine "${cache}/super egg hunt+ setup.exe" /silent
add_launcher "c:\Program Files\Lworks\super egg hunt\superegghunt.exe"

View File

@@ -4,7 +4,7 @@ export winetricksSettings="vd=1024x768"
dialog --backtitle "Audiogame manager" --yesno "If you do not have a full 32 bit gstreamer installation, the Swamp music can cause stuttering and crashes. Would you like to remove the music directory after installation?" -1 -1 --stdout
deleteMusic=$?
download "https://www.kaldobsky.com/audiogames/Swamp.zip"
install_wine_bottle dx8vb quartz corefonts vb6run speechsdk ole32
install_wine_bottle dx8vb quartz corefonts vb6run speechsdk
unzip -d "$WINEPREFIX/drive_c/Program Files/swamp" "${cache}/Swamp.zip"
# make sure the latest version is installed.
if curl -L --output "${cache}/SwampPatch.zip" "https://www.kaldobsky.com/audiogames/SwampPatch.zip" ; then

7
.install/Toy Mania.sh Normal file
View File

@@ -0,0 +1,7 @@
export WINEARCH=win64
export winVer="win7"
get_installer "ToyMania_windows_portable_password_is_GrateCollector.7z" "https://tsatria03.itch.io/toymania"
install_wine_bottle
7z x -o"$WINEPREFIX/drive_c/Program Files/ToyMania" "${cache}/ToyMania_windows_portable_password_is_GrateCollector.7z" -pGrateCollector
find "${WINEPREFIX}/drive_c/Program Files/ToyMania" -type f -name 'nvdaControllerClient64.dll' -exec cp -v "${cache}/nvda2speechd64.dll" "{}" \;
add_launcher "c:\Program Files\ToyMania\tm.exe"

View File

@@ -1,4 +1,3 @@
#
export WINEARCH=win64
export winVer="win7"
download "https://dl.dropbox.com/scl/fi/ukvou0y4gwg21nhhdpj40/Wave-of-the-Undead-Setup.exe?rlkey=4xnuwicpmbkx6w2jo2i56mijg" "https://github.com/RastislavKish/nvda2speechd/releases/download/v0.1/nvda2speechd64.dll"

View File

@@ -324,6 +324,8 @@ download() {
# Add HTML check for other file types
if file -b "${cache}/${dest}" | grep -q "HTML document" ; then
echo "File not found: \"$i\" (HTML document probably 404)"
downloadError=1
else
downloadError=0
fi
;;
@@ -373,6 +375,7 @@ get_bottle() {
"judgement-day"*) ;&
"lockpick"*) ;&
"pigeon-panic"*) ;&
"smashathon"*) ;&
"super-egg-hunt"*) ;&
"super-liam"*) ;&
"the-great-toy-robbery"*) export WINEPREFIX="${HOME}/.local/wine/l-works";;
@@ -632,6 +635,9 @@ winetricks() {
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/winetricks/"
echo "1" > "${XDG_CACHE_HOME:-$HOME/.cache}/winetricks/track_usage"
fi
# Temporary work around for winetricks git bugs. Requires winetricks be installed from package manager.
/usr/bin/winetricks "$@"
return
# Download or update agm's copy of winetricks
if [[ ! -e "${winetricksPath}/winetricks" ]]; then
checkWinetricksUpdate="true"
@@ -665,11 +671,11 @@ install_rhvoice() {
return
fi
declare -A RHVoice=(
[alan]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Alan-v4.0.2008.15-setup.exe"
[bdl]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Bdl-v4.1.2008.15-setup.exe"
[clb]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Clb-v4.0.2008.15-setup.exe"
[alan]="https://github.com/RHVoice/alan-eng/releases/download/4.0/RHVoice-voice-English-Alan-v4.0.2016.21-setup.exe"
[bdl]="https://github.com/RHVoice/bdl-eng/releases/download/4.1/RHVoice-voice-English-Bdl-v4.1.2016.21-setup.exe"
[clb]="https://github.com/RHVoice/clb-eng/releases/download/4.0/RHVoice-voice-English-Clb-v4.0.2016.21-setup.exe"
[lyubov]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Lyubov-v4.0.2008.15-setup.exe"
[slt]="https://rhvoice.eu-central-1.linodeobjects.com/RHVoice-voice-English-Slt-v4.0.2008.15-setup.exe"
[slt]="https://github.com/RHVoice/slt-eng/releases/download/4.1/RHVoice-voice-English-Slt-v4.1.2016.21-setup.exe"
)
voiceName="${voiceName:-bdl}"
voiceName="${voiceName,,}"
@@ -706,7 +712,7 @@ install_wine_bottle() {
# 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)"
geckoPath="$(find /usr/share/wine/ -maxdepth 1 -type d "gecko" 2> /dev/null)"
geckoPath="$(find /usr/share/wine/ -maxdepth 1 -type d -name "gecko" 2> /dev/null)"
if [[ -z "$monoPath" ]]; then
download 'http://dl.winehq.org/wine/wine-mono/6.0.0/wine-mono-6.0.0-x86.msi'
monoPath="${cache}/wine-mono-6.0.0-x86.msi"
@@ -965,10 +971,10 @@ custom_launch_parameters() {
if [[ "${game[0]}" == "sequence-storm" ]]; then
"${0%/*}/speech/clipboard_reader.sh" SequenceStorm &
fi
if [[ "${game[0]}" == "shadow-line" ]]; then
find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
"${0%/*}/speech/clipboard_translator.sh" play_sr.exe shadow-line &
fi
#if [[ "${game[0]}" == "shadow-line" ]]; then
#find "${WINEPREFIX}/drive_c/" -type f -name 'nvdaControllerClient.dll' -exec rm -v "{}" \;
#"${0%/*}/speech/clipboard_translator.sh" play_sr.exe shadow-line &
#fi
if [[ "${game[0]}" == "sketchbook" ]]; then
find "${WINEPREFIX}" -type f -name 'nvdaControllerClient32.dll' -exec cp -v "${cache}/nvdaControllerClient32.dll" "{}" \;
fi
@@ -1052,6 +1058,7 @@ game_launcher() {
done
menuList+=("Donate" "Donate")
menuList+=("Become a Patron" "Become a Patron")
local game=""
game="$(dialog --backtitle "Audio Game Launcher" \
--clear \
--extra-button \
@@ -1060,7 +1067,7 @@ game_launcher() {
--no-tags \
--menu "Please select a game to play" 0 0 0 "${menuList[@]}" --stdout)"
local menuCode=$?
if [[ $menuCode -eq 1 ]]; then
if [[ $menuCode -eq 1 ]] || [[ $menuCode -eq 255 ]]; then
exit 0
elif [[ $menuCode -eq 3 ]]; then
documentation "$game" "$(echo "$game" | cut -d '|' -f2)"
@@ -1153,8 +1160,8 @@ if [[ -z "$DISPLAY" ]]; then
export DISPLAY=":0"
fi
# Settings file
cache="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager"
configFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/games.conf"
export cache="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager"
export configFile="${XDG_CONFIG_HOME:-$HOME/.config}/storm-games/audiogame-manager/games.conf"
mkdir -p "${cache}"
mkdir -p "${configFile%/*}"
# Create the path for AGM's helper programs.

View File

@@ -7,7 +7,6 @@
# 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
if [[ $# -ne 2 ]]; then
echo "Usage: $0 \"application name\" \"file name\"."
exit 1
@@ -22,6 +21,40 @@ fileName="${2,,}"
fileName="${fileName//[[:space:]]/-}.sqlite"
translationFile="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/${fileName}"
# Make sure the directory exists
mkdir -p "$(dirname "$translationFile")"
# Initialize database if it doesn't exist
if [[ ! -s "$translationFile" ]]; then
rm -f "$translationFile"
sqlite3 "$translationFile" <<EOF
CREATE TABLE translations(
text TEXT NOT NULL,
translation TEXT NOT NULL,
PRIMARY KEY (text)
);
CREATE INDEX translations_text_idx ON translations (text);
EOF
fi
# Define a function to safely query the database
query_database() {
local db_file="$1"
local sql_query="$2"
sqlite3 -line "$db_file" "$sql_query"
}
# Define a function to safely insert into the database
insert_database() {
local db_file="$1"
local text="$2"
local translation="$3"
# Use sqlite3 .import feature which is more robust for special characters
echo "$text|$translation" | sqlite3 -separator "|" "$db_file" ".import /dev/stdin temp_import"
sqlite3 "$db_file" "INSERT OR IGNORE INTO translations SELECT * FROM temp_import; DROP TABLE IF EXISTS temp_import;"
}
# Read so long as the application is running
while pgrep -u "$USER" ^$1 &> /dev/null ; do
sleep 0.05
@@ -37,24 +70,6 @@ while pgrep -u "$USER" ^$1 &> /dev/null ; do
if [[ -z "$text" ]]; then
continue
fi
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
# https://en.wikipedia.org/wiki/Unicode_equivalence#Combining_and_precomposed_characters
# https://www.effectiveperlprogramming.com/2011/09/normalize-your-perl-source/
@@ -65,18 +80,32 @@ EOF
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*$//')"
# Normalize text
normalized_text="$(echo "$text" | normalize_unicode)"
# Create a temporary database for import
sqlite3 "$translationFile" "CREATE TABLE IF NOT EXISTS temp_import(text TEXT, translation TEXT);"
# Check if we already have a translation
translated=$(sqlite3 "$translationFile" "SELECT translation FROM translations WHERE text = '$normalized_text' LIMIT 1;" 2>/dev/null)
if [[ -z "$translated" ]]; then
translated="$(trans -no-autocorrect -no-warn -brief "$text" | head -1 | sed 's/\s*$//' | normalize_unicode)"
# Get translation from the trans utility
translated="$(trans -no-autocorrect -no-warn -brief "$normalized_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')"
# Insert using echo piping to avoid escaping issues
echo "$normalized_text|$translated" | sqlite3 -separator "|" "$translationFile" ".import /dev/stdin temp_import"
sqlite3 "$translationFile" "INSERT OR IGNORE INTO translations SELECT * FROM temp_import; DELETE FROM temp_import;"
fi
fi
# If we got a translation, speak it
if [[ -n "$translated" ]]; then
spd-say -- "$translated"
fi
# Clear clipboard
echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null
done