Fix some critters.
After about half an hour of cussin and spitting tobacco juice, I came to some discoveries: * The clipboard translator wasn't even launching successfully. * For BKs 1 and 2, remove the nvda dll thereby forcing it to use the clipboard reader. * Fix up BK2 to go into the right bottle; it is a 32-bit game.
This commit is contained in:
@@ -7,6 +7,13 @@
|
||||
# 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
|
||||
|
||||
# Debug logging
|
||||
#DEBUG_LOG="${XDG_CACHE_HOME:-$HOME/.cache}/audiogame-manager/translator-debug.log"
|
||||
#exec 2>>"$DEBUG_LOG"
|
||||
#echo "=== Translator started at $(date) ===" >&2
|
||||
#echo "Args: $@" >&2
|
||||
#set -x
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: $0 \"application name\" \"file name\"."
|
||||
exit 1
|
||||
@@ -88,21 +95,29 @@ while pgrep -f -u "$USER" "$1" &> /dev/null ; do
|
||||
|
||||
# Check if we already have a translation
|
||||
translated=$(sqlite3 "$translationFile" "SELECT translation FROM translations WHERE text = '$normalizedText' LIMIT 1;" 2>/dev/null)
|
||||
|
||||
echo "DEBUG: Database lookup result: '$translated'" >&2
|
||||
|
||||
if [[ -z "$translated" ]]; then
|
||||
echo "DEBUG: No cached translation, calling trans command" >&2
|
||||
# Get translation from the trans utility
|
||||
translated="$(trans -no-autocorrect -no-warn -brief "$normalizedText" | head -1 | sed 's/\s*$//' | normalizeUnicode)"
|
||||
|
||||
echo "DEBUG: trans returned: '$translated'" >&2
|
||||
|
||||
if [[ -n "$translated" ]]; then
|
||||
# Insert using echo piping to avoid escaping issues
|
||||
echo "$normalizedText|$translated" | sqlite3 -separator "|" "$translationFile" ".import /dev/stdin temp_import"
|
||||
sqlite3 "$translationFile" "INSERT OR IGNORE INTO translations SELECT * FROM temp_import; DELETE FROM temp_import;"
|
||||
echo "DEBUG: Saved to database" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# If we got a translation, speak it
|
||||
if [[ -n "$translated" ]]; then
|
||||
echo "DEBUG: Speaking translation: '$translated'" >&2
|
||||
spd-say -- "$translated"
|
||||
else
|
||||
echo "DEBUG: No translation available, speaking original: '$text'" >&2
|
||||
spd-say -- "$text"
|
||||
fi
|
||||
|
||||
# Clear clipboard
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# Adapted from the bash snippet found at:
|
||||
# https://bbs.archlinux.org/viewtopic.php?id=117031
|
||||
|
||||
|
Reference in New Issue
Block a user