Improvements to the clipboard translator.
This commit is contained in:
parent
52fa738f86
commit
3332cb8d39
@ -20,9 +20,14 @@ while : ; do
|
|||||||
if [[ "${#newText}" -lt 1 ]]; then
|
if [[ "${#newText}" -lt 1 ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
if [[ "${newText}" =~ ^[0-9A-Za-z[:space:][:punct:]]+$ ]]; then
|
||||||
|
spd-say "$newText"
|
||||||
|
echo "" | xclip -d "${DISPLAY:-:0}" -selection clipboard 2> /dev/null
|
||||||
|
continue
|
||||||
|
fi
|
||||||
export newText
|
export newText
|
||||||
translatedText="$(awk -v originalText="${newText}" 'BEGIN { exitCode = 1; FS = "\\)==:\\[" }
|
translatedText="$(awk -v originalText="${newText})==:" 'BEGIN { exitCode = 1; FS = "\\)==:\\[" }
|
||||||
$1~originalText { print $2; exitCode = 0; exit}
|
$0~originalText { print $2; exitCode = 0; exit}
|
||||||
END { exit exitCode }' "$dictionaryFile")"
|
END { exit exitCode }' "$dictionaryFile")"
|
||||||
if [[ "${#translatedText}" -ge 1 ]]; then
|
if [[ "${#translatedText}" -ge 1 ]]; then
|
||||||
spd-say "$translatedText"
|
spd-say "$translatedText"
|
||||||
@ -30,7 +35,7 @@ while : ; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
translatedText="$(trans -b -- "$newText")"
|
translatedText="$(trans -b -- "$newText")"
|
||||||
if [[ "${newText}" != "${translatedText}" ]]; then
|
if ! [[ "${newText}" =~ ^[0-9[:punct:]]+$ ]]; then
|
||||||
echo "${newText})==:[${translatedText}" >> "$dictionaryFile"
|
echo "${newText})==:[${translatedText}" >> "$dictionaryFile"
|
||||||
fi
|
fi
|
||||||
spd-say "$translatedText"
|
spd-say "$translatedText"
|
||||||
|
Loading…
Reference in New Issue
Block a user