From b4050ee79752a4357d10b77ca12c73f78c2f143b Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Wed, 11 May 2022 12:31:24 +0200 Subject: [PATCH] Enforce some Anki discipline --- .bin/get-anki-reviews | 28 ++++++++++++++++++++++++++++ .bin/get-anki-reviews-status | 10 ++++++++++ .bin/stremio | 3 +++ 3 files changed, 41 insertions(+) create mode 100755 .bin/get-anki-reviews create mode 100755 .bin/get-anki-reviews-status create mode 100755 .bin/stremio diff --git a/.bin/get-anki-reviews b/.bin/get-anki-reviews new file mode 100755 index 0000000..dfd1557 --- /dev/null +++ b/.bin/get-anki-reviews @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Get current card count from Anki +count=$(curl -s localhost:8765 -X POST -d '{"action": "getNumCardsReviewedToday", "version": 6}' | jq '.result') + +if [ -z "$count" ] +then + if [ -s /tmp/anki-reviews ]; then + true + else + echo "0" > /tmp/anki-reviews + fi +else + echo "$count" > /tmp/anki-reviews +fi + +num_reviews=$(cat /tmp/anki-reviews) + +if [ "$num_reviews" -ge 400 ];then + color="\x01" + "$(task "Anki reviews" done)" # Check of taskwarrior task +elif [ "$num_reviews" -ge 200 ]; then + color="\x03" +else + color="\x04" +fi + +echo -n -e "$color Reviews: $(python3 -c "print('{:.2%}'.format($num_reviews/400))") \x01" diff --git a/.bin/get-anki-reviews-status b/.bin/get-anki-reviews-status new file mode 100755 index 0000000..fcd9126 --- /dev/null +++ b/.bin/get-anki-reviews-status @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +num_reviews="$(cat /tmp/anki-reviews)" + +if [ "$num_reviews" -ge "400" ] +then + exit 0 +else + exit 1 +fi diff --git a/.bin/stremio b/.bin/stremio new file mode 100755 index 0000000..666169a --- /dev/null +++ b/.bin/stremio @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +get-anki-reviews-status && stremio || $(echo "Do your reviews first" | notify-pipe)