diff options
| author | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-02 14:36:09 +0100 |
|---|---|---|
| committer | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-02 14:36:09 +0100 |
| commit | b8fc75f962891aa7def3b1829d83534350dfe21d (patch) | |
| tree | eec67ec5ae8a65174dcf4cd35439e4c97ce93af9 | |
| download | flashot-b8fc75f962891aa7def3b1829d83534350dfe21d.tar.gz flashot-b8fc75f962891aa7def3b1829d83534350dfe21d.tar.bz2 flashot-b8fc75f962891aa7def3b1829d83534350dfe21d.zip | |
initial commit
works but little input sanitization and pretty inflexible; multiple
scripts for no reason
| -rwxr-xr-x | cards.sh | 22 | ||||
| -rwxr-xr-x | flashcards.sh | 19 | ||||
| -rwxr-xr-x | question_shot.sh | 21 |
3 files changed, 62 insertions, 0 deletions
diff --git a/cards.sh b/cards.sh new file mode 100755 index 0000000..7df324e --- /dev/null +++ b/cards.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# file prefixes cant have underscores or dashes in their names +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 + echo "file = $file" + card=$(echo "$file" | cut -d_ -f2 | cut -d- -f1) + echo "card = $card" + if [[ "$card" = "$old_card" ]] + then + echo "$file\"/>;Card_$card" >> cards.txt + else + # TODO: use printf as echo -n is not portable + /bin/echo -n "<img src=\"$file\"/>;<img src=\"" >> cards.txt + fi + old_card=$card + done +done diff --git a/flashcards.sh b/flashcards.sh new file mode 100755 index 0000000..242d44a --- /dev/null +++ b/flashcards.sh @@ -0,0 +1,19 @@ +#!/bin/sh +action=$(echo "make flashcards\nreset" | dmenu -i -p "action?") +if [ "$action" = "make flashcards" ]; then + confirm=$(echo "no\nyes" | dmenu -i -p "are you sure? screenshot names can overwrite others in media folder") + if [ "$confirm" = "yes" ]; then + cd /tmp/question_shots + combine.sh + cd final + cards.sh + cp *.png ~/.local/share/Anki2/Main/collection.media/ + thunar /tmp/question_shots/final & + echo "yay" | dmenu -p "done! import cards.txt into Anki. remember to reset if done" + fi +elif [ "$action" = "reset" ]; then + confirm=$(echo "no\nyes" | dmenu -i -p "are you sure? this action cannot be undone") + if [ "$confirm" = "yes" ]; then + rm -rf /tmp/question_shots/ + fi +fi diff --git a/question_shot.sh b/question_shot.sh new file mode 100755 index 0000000..a511dec --- /dev/null +++ b/question_shot.sh @@ -0,0 +1,21 @@ +#!/bin/sh +mkdir -p /tmp/question_shots +photoname=$(ls /tmp/question_shots | cut -d_ -f1 | uniq | dmenu -i -p "name of screenshots? (no underscores or hyphens)") +echo "$photoname" +photonumber=$(basename -a $(ls /tmp/question_shots/"$photoname"*) | cut -d_ -f2 | cut -d- -f1 | uniq | tac | dmenu -i -p "number?") + +type=$(echo "question\nanswer" | dmenu -i -p "question or answer?") +if [ "$type" = "question" ]; then + type=q +else + type=a +fi + +partnumber=$(ls /tmp/question_shots/"$photoname"_"$photonumber"-"$type"-* | tail -n1 | cut -d- -f3 | cut -d. -f1) +if [ -z "$partnumber" ]; then + partnumber=0 +else + partnumber=$(echo "$partnumber"+1 | bc) +fi + +scrot -s /tmp/question_shots/"$photoname"_"$photonumber"-"$type"-"$partnumber".png |
