diff options
| author | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-07 17:01:32 +0100 |
|---|---|---|
| committer | not_a_robot06 <temporarythrowaway@tutamail.com> | 2025-07-07 17:01:32 +0100 |
| commit | 5a1dd2e15de2151e29edbc7949f3ddcbbba3e3b3 (patch) | |
| tree | 9f38149ec1394705ea95f0c2b7bcd074363fee07 | |
| parent | be35de785e659cc080dd902cf296b5ce270e2e3f (diff) | |
| download | flashot-5a1dd2e15de2151e29edbc7949f3ddcbbba3e3b3.tar.gz flashot-5a1dd2e15de2151e29edbc7949f3ddcbbba3e3b3.tar.bz2 flashot-5a1dd2e15de2151e29edbc7949f3ddcbbba3e3b3.zip | |
fix README, suppress errors that are irrelevant
| -rw-r--r-- | README.md | 24 | ||||
| -rwxr-xr-x | flashot-make.sh | 11 | ||||
| -rwxr-xr-x | flashot.sh | 11 |
3 files changed, 31 insertions, 15 deletions
@@ -2,13 +2,27 @@ make flashcards out of screenshots, without any manual dragging and dropping! multiple screenshots for one side of a flashcard? no problem! -very useful for turning exam paper questions and answers into flashcards, effortlessly +very useful for turning exam paper questions and answers into flashcards, +effortlessly + +## usage +### flashot.sh +- will prompt for name of flashcard collection +- then prompts for number and type of card, then allows you to take a + screenshot +- no environment variables or commandline arguments + +### flashot-make.sh +- prompts to combine screenshots and import into anki, or to remove all current + screenshots +- environment variable `FLASHOT_ANKI_USER` defines which anki user to copy + screenshots to; default is "Main" ## dependencies - *nix system with X (wayland support later?) -- [https://apps.ankiweb.net/](Anki) +- [Anki](https://apps.ankiweb.net/) - bc - coreutils -- [https://tools.suckless.org/dmenu/](dmenu) -- [https://www.imagemagick.org/](ImageMagick) -- [https://github.com/resurrecting-open-source-projects/scrot](scrot) +- [dmenu](https://tools.suckless.org/dmenu/) +- [ImageMagick](https://www.imagemagick.org/) +- [scrot](https://github.com/resurrecting-open-source-projects/scrot) diff --git a/flashot-make.sh b/flashot-make.sh index 34c921f..f601a94 100755 --- a/flashot-make.sh +++ b/flashot-make.sh @@ -1,16 +1,12 @@ #!/bin/sh combine() { - for name in $(ls | cut -d- -f1-2 | uniq); do + for name in $(ls | cut -d- -f1-2 | uniq | sed 's/final//'); 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 @@ -29,19 +25,20 @@ cards_txt() { if [ -z "$FLASHOT_ANKI_USER" ]; then FLASHOT_ANKI_USER=Main; fi +# main 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 + if [ -d /tmp/flashot/final ]; then rm -rf /tmp/flashot/final; fi 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 + 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 @@ -1,7 +1,12 @@ #!/bin/sh mkdir -p /tmp/flashot -photoname=$(ls /tmp/flashot | cut -d- -f1 | uniq | dmenu -i -p "name of screenshots? (no hyphens)") +if [ -d /tmp/flashot ]; then + photoname=$(ls /tmp/flashot | cut -d- -f1 | uniq | dmenu -i -p "name of screenshots? (no hyphens)") +else + photoname=$(dmenu -i -p "name of screenshots? (no hyphens)") +fi + case "$photoname" in *-* ) printf "ok" | dmenu -p "not a valid name (no hyphens!)" @@ -13,7 +18,7 @@ case "$photoname" in ;; esac -photonumber=$(basename -a $(ls /tmp/flashot/"$photoname"*) | cut -d- -f2 | uniq | tac | dmenu -i -p "number?") +photonumber=$(basename -a $(ls /tmp/flashot/"$photoname"* 2>/dev/null) 2>/dev/null | cut -d- -f2 | uniq | tac | dmenu -i -p "number?") type=$(printf "question\nanswer" | dmenu -i -p "question or answer?") if [ "$type" = "question" ]; then @@ -22,7 +27,7 @@ else type=a fi -partnumber=$(ls /tmp/flashot/"$photoname"-"$photonumber"-"$type"-* | tail -n1 | cut -d- -f4 | cut -d. -f1) +partnumber=$(ls /tmp/flashot/"$photoname"-"$photonumber"-"$type"-* 2>/dev/null | tail -n1 | cut -d- -f4 | cut -d. -f1) if [ -z "$partnumber" ]; then partnumber=0 else |
