Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
-rwxr-xr-xmakeDir.sh2
-rwxr-xr-xswipeGuess.sh11
2 files changed, 11 insertions, 2 deletions
diff --git a/makeDir.sh b/makeDir.sh
index aa9f782..863497e 100755
--- a/makeDir.sh
+++ b/makeDir.sh
@@ -1,7 +1,7 @@
#!/bin/sh
dir="$1"
rm $dir/*
-source functions.sh
+source "$(dirname "$0")/functions.sh"
while read -r line; do
fl=$(firstLetter "$line")
ll=$(lastLetter "$line")
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