From 229f4fb10ad52f68401af9b91e91145320f3a9d8 Mon Sep 17 00:00:00 2001 From: Patrick <24683548+pohuing@users.noreply.github.com> Date: Mon, 15 Mar 2021 02:29:17 +0100 Subject: [PATCH] Updated README.md Added example __init__.py to change environment variables As of 2.1.28 Anki looks only at the environment variables for overriding endpoints Signed-off-by: Patrick <24683548+pohuing@users.noreply.github.com> --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index e3e5653..c445e80 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,21 @@ Follow [these instructions](https://github.com/kuklinistvan/docker-anki-sync-ser Setting up Anki --------------- +### Anki >= 2.1.28 + +Create a new directory in [the add-ons folder][addons21] (name it something +like ankisyncd), create a file named `__init__.py` containing the code below +and put it in the `ankisyncd` directory. + + import anki.sync, anki.hooks, aqt, os + + addr = "http://127.0.0.1:27701/" # put your server address here + os.environ["SYNC_ENDPOINT"] = addr + "sync/" + os.environ["SYNC_ENDPOINT_MEDIA"] = addr + "msync/" + def resetHostNum(): + aqt.mw.pm.profile['hostNum'] = None + anki.hooks.addHook("profileLoaded", resetHostNum) + ### Anki 2.1 Create a new directory in [the add-ons folder][addons21] (name it something