From 1a18ec96509414fc4f2e297fb8901f038a412f0c Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 29 Jun 2022 07:59:58 -0400 Subject: rename behavior scripts for consistency --- predictor.sh | 66 ----------------------------------------------------- sb_picker.sh | 32 ++++++++++++++++++++++++++ sb_predictor.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ swipeGuessPicker.sh | 32 -------------------------- 4 files changed, 98 insertions(+), 98 deletions(-) delete mode 100755 predictor.sh create mode 100755 sb_picker.sh create mode 100755 sb_predictor.sh delete mode 100755 swipeGuessPicker.sh diff --git a/predictor.sh b/predictor.sh deleted file mode 100755 index 7fd4998..0000000 --- a/predictor.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -sock="$XDG_RUNTIME_DIR/predictor.sock" -kl="$XDG_RUNTIME_DIR/keylog" -lw="$kl/pred.lastword" -tw="$kl/pred.tfw" -complete="$XDG_RUNTIME_DIR/pred.complete.bool" -words=~/.local/share/sxmo/words.txt -twow=~/.local/share/sxmo/count_2w.txt -keymap=~/.local/share/sxmo/keyboard.map.tsv -rm -f "$sock" "$lw" "$complete" -mkdir -p "$kl" -chmod 700 "$kl" -mkfifo "$sock" -saveWord(){ - IFS='' - while read -r word; do - echo "$word" - if echo "$word" |grep -q " "; then - printf %s "$word" | cut -d' ' -f1 >> "$lw" - printf " " >> "$lw" - mv "$lw" "$tw" - word="$(printf %s "$word"| cut -d' ' -f2| tee "$lw")" - else - printf %s "$word" >> "$lw" - word="$(cat "$lw")" - fi - rm -f "$complete" - cat "$words" "$twow" | quick5 "$word" >> "$sock" - done -} -typeSomehow(){ - IFS='' - while read -r word; do - if test -e "$complete"; then - test -n "${word:1}" && wl-ime-type -- "${word:1}" - else - wl-ime-type -- "$word" - fi - done -} -cat 0<> "$sock"|suggpicker 2>/dev/null|saveWord | typeSomehow & -IFS='' -while read -r swipe; do - if test -n "${swipe:1}"; then - touch "$complete" - # TODO: change words - echo "$swipe" | swipeGuess "$words" 5 >> "$sock" - else - if test "$swipe" = " "; then - if test -e "$lw"; then - printf " " >> "$lw" - rm -f "$complete" - cat "$twow" | quick5 "$(cat "$lw")" >> "$sock" - mv "$lw" "$tw" - fi - elif test "$swipe" = "$(echo -e "\x08")"; then - lastword="$(cat "$lw")" - printf %s "$lastword" | sed 's/.$//g' > "$lw" - elif test "$swipe" = "$(echo -e "\n")"; then - rm -f "$lw" "$tw" - else - printf %s "$swipe" >> "$lw" - fi - fi -done -killall suggpicker diff --git a/sb_picker.sh b/sb_picker.sh new file mode 100755 index 0000000..69dda6e --- /dev/null +++ b/sb_picker.sh @@ -0,0 +1,32 @@ +#!/bin/sh +sock="$XDG_RUNTIME_DIR/sgp.sock" +words=~/.local/share/sxmo/words.txt +keymap=~/.local/share/sxmo/keyboard.map.tsv +rm "$sock" +mkfifo "$sock" +cat 0<> "$sock"|suggpicker 2>/dev/null|completelyTypeWord.sh & +swipeGuess "$words" 5 | while read -r word; do + set -- $word + if test -n "$2"; then + s1="$(echo "$1" | mapScore "$keymap" bee|cut -f1)" + s2="$(echo "$2" | mapScore "$keymap" bee |cut -f1)" + cutoff="$(( ($s1 * 19 / 20) - 2 ))" + if [ "$s2" -lt "$cutoff" ]; then + set -- "$1" + elif [ -n "$4" ]; then + s4="$(echo "$4" | mapScore "$keymap" bee |cut -f1)" + if [ "$s4" -lt "$cutoff" ]; then + set -- "$1" "$2" "$3" + fi + fi + fi + if test "$1" && ! test "$2"; then + wtype "${1:1}" + elif ! test "$2"; then + echo "" >> "$sock" + else + echo "$word" >> "$sock" + fi +done + +killall suggpicker diff --git a/sb_predictor.sh b/sb_predictor.sh new file mode 100755 index 0000000..7fd4998 --- /dev/null +++ b/sb_predictor.sh @@ -0,0 +1,66 @@ +#!/bin/sh +sock="$XDG_RUNTIME_DIR/predictor.sock" +kl="$XDG_RUNTIME_DIR/keylog" +lw="$kl/pred.lastword" +tw="$kl/pred.tfw" +complete="$XDG_RUNTIME_DIR/pred.complete.bool" +words=~/.local/share/sxmo/words.txt +twow=~/.local/share/sxmo/count_2w.txt +keymap=~/.local/share/sxmo/keyboard.map.tsv +rm -f "$sock" "$lw" "$complete" +mkdir -p "$kl" +chmod 700 "$kl" +mkfifo "$sock" +saveWord(){ + IFS='' + while read -r word; do + echo "$word" + if echo "$word" |grep -q " "; then + printf %s "$word" | cut -d' ' -f1 >> "$lw" + printf " " >> "$lw" + mv "$lw" "$tw" + word="$(printf %s "$word"| cut -d' ' -f2| tee "$lw")" + else + printf %s "$word" >> "$lw" + word="$(cat "$lw")" + fi + rm -f "$complete" + cat "$words" "$twow" | quick5 "$word" >> "$sock" + done +} +typeSomehow(){ + IFS='' + while read -r word; do + if test -e "$complete"; then + test -n "${word:1}" && wl-ime-type -- "${word:1}" + else + wl-ime-type -- "$word" + fi + done +} +cat 0<> "$sock"|suggpicker 2>/dev/null|saveWord | typeSomehow & +IFS='' +while read -r swipe; do + if test -n "${swipe:1}"; then + touch "$complete" + # TODO: change words + echo "$swipe" | swipeGuess "$words" 5 >> "$sock" + else + if test "$swipe" = " "; then + if test -e "$lw"; then + printf " " >> "$lw" + rm -f "$complete" + cat "$twow" | quick5 "$(cat "$lw")" >> "$sock" + mv "$lw" "$tw" + fi + elif test "$swipe" = "$(echo -e "\x08")"; then + lastword="$(cat "$lw")" + printf %s "$lastword" | sed 's/.$//g' > "$lw" + elif test "$swipe" = "$(echo -e "\n")"; then + rm -f "$lw" "$tw" + else + printf %s "$swipe" >> "$lw" + fi + fi +done +killall suggpicker diff --git a/swipeGuessPicker.sh b/swipeGuessPicker.sh deleted file mode 100755 index 69dda6e..0000000 --- a/swipeGuessPicker.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -sock="$XDG_RUNTIME_DIR/sgp.sock" -words=~/.local/share/sxmo/words.txt -keymap=~/.local/share/sxmo/keyboard.map.tsv -rm "$sock" -mkfifo "$sock" -cat 0<> "$sock"|suggpicker 2>/dev/null|completelyTypeWord.sh & -swipeGuess "$words" 5 | while read -r word; do - set -- $word - if test -n "$2"; then - s1="$(echo "$1" | mapScore "$keymap" bee|cut -f1)" - s2="$(echo "$2" | mapScore "$keymap" bee |cut -f1)" - cutoff="$(( ($s1 * 19 / 20) - 2 ))" - if [ "$s2" -lt "$cutoff" ]; then - set -- "$1" - elif [ -n "$4" ]; then - s4="$(echo "$4" | mapScore "$keymap" bee |cut -f1)" - if [ "$s4" -lt "$cutoff" ]; then - set -- "$1" "$2" "$3" - fi - fi - fi - if test "$1" && ! test "$2"; then - wtype "${1:1}" - elif ! test "$2"; then - echo "" >> "$sock" - else - echo "$word" >> "$sock" - fi -done - -killall suggpicker -- cgit 1.4.1