aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/udt-appthemes26
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/udt-appthemes b/bin/udt-appthemes
index eedc144..37d3e63 100755
--- a/bin/udt-appthemes
+++ b/bin/udt-appthemes
@@ -17,19 +17,33 @@ from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
SNIPPET = "udt"
-VAULT_ROOT = Path.home() / "Documents" / "Obsidian"
+OBSIDIAN_REGISTRY = Path.home() / ".config" / "obsidian" / "obsidian.json"
TYPORA_THEMES = Path.home() / ".config" / "Typora" / "themes"
def vaults():
- """Every Obsidian vault under the vault root.
+ """The vaults Obsidian itself knows about.
- A vault is any directory holding a .obsidian config dir. Nested vaults are
- real: a vault inside another vault's folder is still its own vault.
+ Read from Obsidian's own registry rather than found by scanning for
+ .obsidian directories. A scan cannot tell a vault from an abandoned one:
+ ~/Documents/Obsidian holds a leftover .obsidian from a vault that no longer
+ exists, and writing to it touched config for something Obsidian never
+ opens.
"""
- if not VAULT_ROOT.is_dir():
+ try:
+ data = json.loads(OBSIDIAN_REGISTRY.read_text())
+ except (OSError, json.JSONDecodeError):
return []
- return sorted(p for p in VAULT_ROOT.rglob(".obsidian") if p.is_dir())
+
+ found = []
+ for entry in data.get("vaults", {}).values():
+ path = entry.get("path")
+ if not path:
+ continue
+ config = Path(path) / ".obsidian"
+ if config.is_dir():
+ found.append(config)
+ return sorted(found)
def install_obsidian(source):