SaveManager
Using the SaveManager addon to manage themes in Obsidian
What is the SaveManager?
The SaveManager is an addon that allows you to save, load, delete and set autoload configurations in Obsidian.
Quick Start
To quickly get started with the SaveManager addon, you can use the following code:
API Reference
Methods
SetLibrary
Sets the library to use for the SaveManager.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Library to use for the SaveManager | Library (table) | nil |
SetFolder
Sets the folder to use for the SaveManager.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Folder path relative to workspace | string | nil |
SetSubFolder
Sets the subfolder to use for the SaveManager. This is not required, but can be used to save configs for specific places inside of the game.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Subfolder to use for the SaveManager | string | nil |
SetIgnoreIndexes
Sets the indexes to ignore when saving configs.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Indexes to ignore when saving configs (e.g. { "MenuKeybind" }) | table | nil |
IgnoreThemeSettings
Adds the default theme-related indexes to the ignore list so configs do not override user themes.
Save
Serializes the current library state to a JSON file inside the configured folder tree.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | File name without extension | string | nil |
Returns boolean, string? where the second value contains an error message when the save fails.
Load
Loads a JSON configuration produced by the save method and applies it to the library controls.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | File name without extension | string | nil |
Returns boolean, string? describing the outcome.
Delete
Removes a configuration file from disk.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | File name without extension | string | nil |
Returns boolean, string? describing the outcome.
RefreshConfigList
Scans the folder tree and returns an array of available configuration names (without extensions).
Returns { string } of config names.
GetAutoloadConfig
Reads the persistent autoload marker and returns the config name that should be auto-loaded.
Returns a string representing the config name or the literal value "none".
LoadAutoloadConfig
Loads and applies the configuration marked for autoload if a name is stored on disk.
SaveAutoloadConfig
Sets the configuration that should load automatically on script startup.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Config name to mark for autoload | string | nil |
Returns boolean, string? describing the outcome.
DeleteAutoLoadConfig
Clears the autoload marker so no configuration is loaded automatically.
Returns boolean, string? describing the outcome.
BuildConfigSection
Creates the SaveManager UI in your library tab so users can create, load, overwrite and manage configs directly.
| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Tab to populate | Tab (table) | nil |
This call also ignores the config management controls when saving.