Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
Diffstat (limited to 'swipeGuess.sh')
-rwxr-xr-xswipeGuess.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/swipeGuess.sh b/swipeGuess.sh
index 092c1ee..857f792 100755
--- a/swipeGuess.sh
+++ b/swipeGuess.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+source "$(dirname "$0")/functions.sh"
+
swipeToQuery(){
swipe=$(echo "$1" | tr -d "'.\*\"\\^$\(\)")
printf '^'
@@ -13,11 +15,18 @@ swipeToQuery(){
query(){
swipe="$2"
wordlist="$1"
+ wordfile="$wordlist"
+ if test -d "$wordlist"; then
+ wordfile=/dev/null
+ fl=$(firstLetter "$swipe")
+ ll=$(lastLetter "$swipe")
+ test -f "$wordlist/$fl$ll" && wordfile="$wordlist/$fl$ll"
+ fi
query=$(swipeToQuery "$swipe")
echo "query: $query" > /dev/stderr
# -m 1: just give first result
- grep -m 1 "$query" "$wordlist"
+ grep -m 1 "$query" "$wordfile"
}
while read -r line; do