diff options
| author | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-06 23:07:38 +0100 |
|---|---|---|
| committer | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-06 23:07:38 +0100 |
| commit | be35de785e659cc080dd902cf296b5ce270e2e3f (patch) | |
| tree | d2c5f630b79aaa299d8922f7584a406d15c00672 /flashot-make.sh | |
| parent | b8fc75f962891aa7def3b1829d83534350dfe21d (diff) | |
| download | flashot-be35de785e659cc080dd902cf296b5ce270e2e3f.tar.gz flashot-be35de785e659cc080dd902cf296b5ce270e2e3f.tar.bz2 flashot-be35de785e659cc080dd902cf296b5ce270e2e3f.zip | |
first proper version
- use hyphens only for separation
- only two scripts: one for screenshots and one for making the cards
- add README
- a little bit of error checking
- TODO: if question or answer non existent, then don't break cards.txt
Diffstat (limited to 'flashot-make.sh')
| -rwxr-xr-x | flashot-make.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/flashot-make.sh b/flashot-make.sh new file mode 100755 index 0000000..34c921f --- /dev/null +++ b/flashot-make.sh @@ -0,0 +1,50 @@ +#!/bin/sh +combine() { + for name in $(ls | cut -d- -f1-2 | uniq); do + magick "$name"-q* -append final/"$name"-0.png + magick "$name"-a* -append final/"$name"-1.png + done +} + +cards_txt() { + if [ $(ls cards.txt) ]; then + rm cards.txt + fi + + for name in $(ls *.png | cut -d- -f1 | uniq); do + old_card=-1 + for file in "$name"*; do + card=$(printf "$file" | cut -d- -f2 | cut -d. -f1) + if [[ "$card" = "$old_card" ]] + then + echo "$file\"/>;Card_$card" >> cards.txt + else + printf "<img src=\"%s\"/>;<img src=\"" "$file" >> cards.txt + fi + old_card=$card + done + done +} + +if [ -z "$FLASHOT_ANKI_USER" ]; then FLASHOT_ANKI_USER=Main; fi + + +action=$(printf "make flashcards\nreset" | dmenu -i -p "action?") +if [ "$action" = "make flashcards" ]; then + confirm=$(printf "no\nyes" | dmenu -i -p "are you sure? screenshot names can overwrite others in media folder") + if [ "$confirm" = "yes" ]; then + cd /tmp/flashot + mkdir -p final + combine + cd final + cards_txt + cp *.png ~/.local/share/Anki2/"$FLASHOT_ANKI_USER"/collection.media/ + anki /tmp/flashot/final/cards.txt + fi + +elif [ "$action" = "reset" ]; then + confirm=$(printf "no\nyes" | dmenu -i -p "are you sure? this action cannot be undone") + if [ "$confirm" = "yes" ]; then + rm -rf /tmp/flashot/ + fi +fi |
