dot_testing/builds/utils/anki-advance-conjugation

56 lines
1.1 KiB
Plaintext
Executable File

# when there's an open anki window, and we're entering conjugations for verbs
# or whatever, it's nice to automatically advance the conjugation form.
# for instance, if your card key is:
# What is the yo form conjugation for ir in the imperfect?
# Your next one will naturally be
# What is the tú form conjugation for ir in the imperfect?
sleep 0.25
# firstly, get the card key text
xdotool sleep 0.2 key ctrl+a ctrl+c
sleep 0.25
# now the key is in our clipboard
text=$(xclip -out -selection clipboard)
form=$(echo "$text" | sed '
s/.*\( yo \).*/\1/;
s/.*\( tú \).*/\1/;
s/.*\( él\/ella\/usted \).*/\1/;
s/.*\( nosotros \).*/\1/;
s/.*\( vosotros \).*/\1/;
s/.*\( ustedes \).*/\1/
')
case "$form" in
" yo ")
next="tú"
;;
" tú ")
next="él/ella/usted"
;;
" él/ella/usted ")
next="nosotros"
;;
" nosotros ")
next="vosotros"
;;
" vosotros ")
next="ustedes"
;;
" ustedes ")
next="yo"
;;
esac
printf "text: %s\n" "$text"
printf "form: %s\n" "$form"
printf "next: %s\n" "$next"
new_text=$(echo "$text" | sed "s|$form| $next |g")
echo -n "$new_text" | xclip -in -selection clipboard
xdotool key ctrl+a ctrl+v