Syncing addons and their configuration

As the title suggest, it would be nice if the list of the addons of a certain profile, alongside with configuration of the addons, would be synced. It doesn’t require a lot of space, and would improve the UX when one has Anki installed on many computers.

The only problem would be if you tried to sync different versions of Anki, the addons might not be available similarly everywhere, but you could just force the addon to be disabled non-supported Anki versions.

1 Like

I can’t agree more. Compared to media folder, addons are really light-weight, and having the same settings on all devices would be enormously more convenient than installing them yourself every time

Not sure but this could be done with an addon working something like this (depends on whether addons have access to write into the media which I think they do?):

  • For each addon in the addon folder, copy the config.json as _<addon_folder_name>_config.json into the media folder
  • Get changes to config from this file

Doing this automatically on sync might be terrific exercise in building a file syncing system within that properly detects which changes are the latest ones and handles conflicts intelligently.

  • Need set timestamps on the file and only save configs when there are changes compared to the current ones
  • Only replace current configs with the media folder version when there were no changes in your current state
  • When closing Anki, you can save your changes but not load them of course
  • When opening Anki, you’d get changes from the media files + possibly conflicts
  • Some way to handle conflicts (you’ve got Anki open on two devices and made changes to configs on both, then tried syncing). Show a prompt to pick which ones to use.

Or you could just press a button in anki to save current configs into the media folder and another button to load them from the media folder

I don’t use Anki anymore in my everyday life because I don’t really have any use for it anymore (even though I still think it’s a terrific piece of software), so I’m not going to spend some time implementing this.

Yet, here are some tips if anyone is interested in doing so.

  1. Timestamps are a imprecise and inefficient way to detect changes in files.
    • Imprecise, in the sense that they are a lot of gotchas in relying on that information to know whether a file has changed since last time you checked it out. See this blog post for more information about how can you do better.
    • Inefficient, because it doesn’t get triggered when the file changes, it forces you to spend time to do (potentially useless) checks. Instead, you might want to watch for file changes (which in Linux can be achieved using inotify).
  2. Merges are hard, you probably don’t even want to try merging, as that would probably involve more work in doing right than the rest of the project. However, good news! Since you use Anki’s collection, and hence Anki’s sync mechanisme, you don’t need to implement that yourself.
  3. You’d probably want to do flush every local config changes to the local collection right before every sync (for which Anki probably has a hook), and similarly restore config from the local collection right after every sync.

Well, I made the very simple two button version now. It works though a big gotcha is accidentally clicking Read instead of Save after making some config edits and wanting to sync them.

https://ankiweb.net/shared/info/60290354