diff options
| author | Caroline Larimore <caroline@larimo.re> | 2025-06-28 23:24:11 -0700 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2025-06-29 11:50:08 -0700 |
| commit | c056c86702755d966264fd52b25a293e7a822015 (patch) | |
| tree | 6a5c1d5fe760d24f724a5acdebea35c1fd428934 /modules/home | |
| parent | 83058ca0edcf0b2165dfba5d2574554af71ccfb2 (diff) | |
polybar: add anki review module
Diffstat (limited to 'modules/home')
| -rw-r--r-- | modules/home/desktop/components/polybar/default.nix | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/modules/home/desktop/components/polybar/default.nix b/modules/home/desktop/components/polybar/default.nix index f6b81db..468aacd 100644 --- a/modules/home/desktop/components/polybar/default.nix +++ b/modules/home/desktop/components/polybar/default.nix @@ -64,7 +64,7 @@ in { module.margin = 1; modules = { - left = "stat music"; + left = "stat music anki"; center = "i3"; right = "wlan eth filesystem keyboard xkeyboard pulseaudio date"; }; @@ -114,6 +114,44 @@ in { }; }; + "module/anki" = { + type = "custom/script"; + + interval = 600; + interval-fail = 10; + + exec = pkgs.writeShellScript "get-anki-status" '' + count="$(${pkgs.sqlite}/bin/sqlite3 --readonly ~/.local/share/Anki2/$(whoami)/collection.anki2 <<EOF + SELECT + count() + FROM cards JOIN col + WHERE + queue = 2 AND + datetime(col.crt, 'unixepoch', '+' || due || ' day') + <= datetime('now', 'localtime') + EOF + )" + + if ! [[ "$count" =~ ^[0-9]+$ ]]; then + echo ":3" + exit 1 + fi + + if [[ "$count" -eq 0 ]]; then + exit + fi + + echo "$count" + ''; + + format = { + prefix = { + text = " "; + foreground = "#${c.accent}"; + }; + }; + }; + "module/i3" = { type = "internal/i3"; |