mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Updated logic to find Obsidian vault regardless of location (#2668)
Co-authored-by: Ryan Hughes <ryan@heyoodle.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
# omarchy-theme-set-obsidian: Bootstrap and update Omarchy theme for Obsidian
|
# omarchy-theme-set-obsidian: Bootstrap and update Omarchy theme for Obsidian
|
||||||
#
|
#
|
||||||
# - Ensures registry at ~/.local/state/omarchy/obsidian-vaults
|
# - Ensures registry at ~/.local/state/omarchy/obsidian-vaults
|
||||||
# - If missing/empty, bootstraps by scanning ~/Documents/*/.obsidian and ~/Dropbox/*/.obsidian
|
# - Populates by extracting vault paths from ~/.config/obsidian/obsidian.json
|
||||||
# - For each valid vault:
|
# - For each valid vault:
|
||||||
# - Ensures .obsidian/themes/Omarchy/{manifest.json, theme.css}
|
# - Ensures .obsidian/themes/Omarchy/{manifest.json, theme.css}
|
||||||
# - Updates theme.css (uses current theme’s obsidian.css if present; otherwise generates -- see below)
|
# - Updates theme.css (uses current theme’s obsidian.css if present; otherwise generates -- see below)
|
||||||
@@ -26,30 +26,18 @@
|
|||||||
VAULTS_FILE="$HOME/.local/state/omarchy/obsidian-vaults"
|
VAULTS_FILE="$HOME/.local/state/omarchy/obsidian-vaults"
|
||||||
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
||||||
|
|
||||||
# Ensure the vaults registry exists, or bootstrap from known locations
|
|
||||||
ensure_vaults_file() {
|
ensure_vaults_file() {
|
||||||
mkdir -p "$(dirname "$VAULTS_FILE")"
|
mkdir -p "$(dirname "$VAULTS_FILE")"
|
||||||
# If file exists (even empty), do not scan; treat as authoritative
|
|
||||||
if [ -f "$VAULTS_FILE" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local tmpfile
|
local tmpfile
|
||||||
tmpfile="$(mktemp)"
|
tmpfile="$(mktemp)"
|
||||||
# Scan a couple of common locations for <base>/<vault>/.obsidian
|
# Extract the Obsidian vault location from config file <base>/<vault>/.obsidian
|
||||||
for base in "$HOME/Documents" "$HOME/Dropbox"; do
|
jq -r '.vaults | values[].path' ~/.config/obsidian/obsidian.json 2>/dev/null >>"$tmpfile"
|
||||||
[ -d "$base" ] || continue
|
if [ -s "$tmpfile" ]; then
|
||||||
for d in "$base"/*/.obsidian; do
|
sort -u "$tmpfile" >"$VAULTS_FILE"
|
||||||
[ -d "$d" ] || continue
|
else
|
||||||
vault_dir="${d%/.obsidian}"
|
: >"$VAULTS_FILE"
|
||||||
printf "%s\n" "$vault_dir" >>"$tmpfile"
|
fi
|
||||||
done
|
rm "$tmpfile"
|
||||||
done
|
|
||||||
if [ -s "$tmpfile" ]; then
|
|
||||||
sort -u "$tmpfile" >"$VAULTS_FILE"
|
|
||||||
else
|
|
||||||
: >"$VAULTS_FILE"
|
|
||||||
fi
|
|
||||||
rm -f "$tmpfile"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensure theme directory and minimal manifest exist in a vault
|
# Ensure theme directory and minimal manifest exist in a vault
|
||||||
|
|||||||
Reference in New Issue
Block a user