From 8b8731e089575a4bf3b9b308e26b38f4dad47511 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 11 Sep 2026 19:00:56 +0200 Subject: fix(appthemes): take Obsidian vaults from its registry, not a directory scan The installer found vaults by scanning ~/Documents/Obsidian for .obsidian directories, which cannot tell a vault from a leftover. That parent folder holds an abandoned .obsidian from a vault that no longer exists, so the scan found six vaults where Obsidian knows five, and the extra one got a snippet and an edited appearance.json for something Obsidian never opens. It now reads ~/.config/obsidian/obsidian.json, which is the list Obsidian itself maintains, and only writes to a path that is both registered and still has a .obsidian directory. The stray directory has been restored to its previous contents. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_015gbjA2bmswN8jyPDKzrvqe --- bin/udt-appthemes | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'bin/udt-appthemes') 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): -- cgit v1.2.3