22
33## Config JSON
44
5- If you include a config.json file with a JSON dictionary in it, Anki
6- will allow users to edit it from the add-on manager.
7-
8- A simple example: in config.json:
5+ Add-ons can store config data in a JSON dictionary. You provide the
6+ default values by shipping a file called ` config.json ` . A simple example:
97
108 {"myvar": 5}
119
@@ -21,12 +19,7 @@ config = mw.addonManager.getConfig(__name__)
2119print (" var is" , config[' myvar' ])
2220```
2321
24- When updating your add-on, you can make changes to config.json. Any
25- newly added keys will be merged with the existing configuration.
26-
27- If you change the value of existing keys in config.json, users who have
28- customized their configuration will continue to see the old values
29- unless they use the "restore defaults" button.
22+ If the config hasn't been customized, the default values from that file will be used.
3023
3124If you need to programmatically modify the config, you can save your
3225changes with:
@@ -35,6 +28,17 @@ changes with:
3528mw.addonManager.writeConfig(__name__ , config)
3629```
3730
31+ Users are also able to edit the config inside the GUI.
32+
33+ The edited config is stored in ` meta.json ` .
34+
35+ When ` getConfig() ` is used after edits, meta.json is used preferentially. If a key
36+ is missing from meta.json's config, Anki will fall back on the default config.
37+
38+ If you change the value of existing keys in config.json, users who have
39+ customized their configuration will continue to see the old values
40+ unless they use the "restore defaults" button.
41+
3842If no config.json file exists, getConfig() will return None - even if
3943you have called writeConfig().
4044
0 commit comments