commit 2f3b1c58287715a0e59f9eb7de5385aa8be0783a parent 2967980ebdb8f90bc6f82acb05b8dea1425431c3 Author: Stefan Koch <programming@stefan-koch.name> Date: Sun, 4 Jul 2021 16:16:41 +0200 create a script to display Anki progress Diffstat:
M | README.md | | | 11 | +++++++++++ |
A | anki | | | 15 | +++++++++++++++ |
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -1,2 +1,13 @@ # anki-i3blocks + Script to display Anki Deck stats in i3blocks status bar + + +## Usage + +``` +[wanikani] +command=~/anki Spanish +label=ES +interval=600 +``` diff --git a/anki b/anki @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +deck=$1 + +if [[ -z $ANKI_COLLECTION_PATH ]]; then + ANKI_COLLECTION_PATH="$HOME/.local/share/Anki2/User 1/collection.anki2" +fi + +learning_query="SELECT COUNT(*) FROM cards c JOIN decks d ON c.did = d.id WHERE d.name = '$deck' COLLATE NOCASE AND c.ivl != 0;" +all_query="SELECT COUNT(*) FROM cards c JOIN decks d ON c.did = d.id WHERE d.name = '$deck' COLLATE NOCASE;" + +learning_count=$(sqlite3 "$ANKI_COLLECTION_PATH" "$learning_query") +all_count=$(sqlite3 "$ANKI_COLLECTION_PATH" "$all_query") + +echo $learning_count/$all_count