Phase B verdict on two unused? entries in the theme-engine scripts. - nomarchy-theme-set-obsidian: real script that copies the active theme's obsidian.css into every Obsidian vault under ~/.config/obsidian/obsidian.json. Wires it into nomarchy-theme-set next to the btop/opencode hot-reloads. Self-gates twice (no obsidian.css → exit 0; no .obsidian dir → continue), so it's a no-op for users without Obsidian. - nomarchy-theme-set-vscode: delete-dead. Its own comment admitted it was "mostly a placeholder"; its only action (nomarchy-env-update) is already done unconditionally upstream by nomarchy-theme-set. The NOMARCHY_TOGGLE_SKIP_VSCODE_THEME env var it gated on is exported by features/scripts/default.nix:73 from nomarchy.toggles.skipVsCodeTheme, but with this script gone there are no consumers; the toggle survives as a public option until a follow-up wires it through the VSCode module properly. SCRIPTS.md regenerated: unused? 34 → 32, kept 165 → 166. nix flake check clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
76 lines
3.0 KiB
Bash
Executable File
76 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Set the system theme declaratively.
|
|
# Usage: nomarchy-theme-set <theme-name>
|
|
|
|
THEME_NAME="$1"
|
|
|
|
if [[ -z $THEME_NAME ]]; then
|
|
echo "Usage: nomarchy-theme-set <theme-name>"
|
|
exit 1
|
|
fi
|
|
|
|
STATE_DIR="$HOME/.config/nomarchy"
|
|
STATE_FILE="$STATE_DIR/state.json"
|
|
|
|
# Resolve themes directory (Built-in from Nix store via Home Manager, or user extra)
|
|
if [ -d "$HOME/.config/nomarchy/themes/$THEME_NAME" ]; then
|
|
THEMES_DIR="$HOME/.config/nomarchy/themes"
|
|
else
|
|
THEMES_DIR="$HOME/.local/share/nomarchy/themes"
|
|
fi
|
|
|
|
mkdir -p "$STATE_DIR"
|
|
[[ ! -f $STATE_FILE ]] && echo "{}" > "$STATE_FILE"
|
|
|
|
if [ ! -d "$THEMES_DIR/$THEME_NAME" ] && ! [[ "$THEME_NAME" == "nord" ]]; then
|
|
echo "Theme '$THEME_NAME' not found in $THEMES_DIR"
|
|
fi
|
|
|
|
TMP_JSON=$(mktemp)
|
|
jq --arg theme "$THEME_NAME" '.theme = $theme' "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
|
|
|
|
# Sync to system state if we have permissions (for system-level theming like browser policies)
|
|
SYSTEM_STATE_FILE="/etc/nixos/state.json"
|
|
if [ -w "$SYSTEM_STATE_FILE" ] || [ -w "/etc/nixos" ]; then
|
|
sudo jq --arg theme "$THEME_NAME" '.theme = $theme' "$SYSTEM_STATE_FILE" > /tmp/system-state.json 2>/dev/null && sudo mv /tmp/system-state.json "$SYSTEM_STATE_FILE" 2>/dev/null || true
|
|
fi
|
|
|
|
# Try to find a background for this theme
|
|
BG_DIR="$THEMES_DIR/$THEME_NAME/backgrounds"
|
|
if [ -d "$BG_DIR" ]; then
|
|
BG=$(ls "$BG_DIR" | head -n 1)
|
|
if [ -n "$BG" ]; then
|
|
TMP_JSON=$(mktemp)
|
|
jq --arg wp "$BG_DIR/$BG" '.wallpaper = $wp' "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
|
|
fi
|
|
fi
|
|
|
|
echo "Theme set to $THEME_NAME. Applying changes with nomarchy-env-update..."
|
|
nomarchy-env-update
|
|
|
|
nomarchy-theme-set-templates
|
|
|
|
# Walker reads its CSS via @import of ~/.config/nomarchy/current/theme/apps/walker/style.css,
|
|
# and waybar's shared fallback style does the same with waybar.css. HM's sd-switch
|
|
# only restarts services whose unit *definition* changed, so when only the imported
|
|
# file's contents change, neither gets reloaded. Restart them explicitly.
|
|
command -v nomarchy-restart-walker >/dev/null 2>&1 && nomarchy-restart-walker || true
|
|
command -v nomarchy-restart-waybar >/dev/null 2>&1 && nomarchy-restart-waybar || true
|
|
|
|
# Hot-reload long-running TUIs / agents that read their colors from
|
|
# the active-theme symlink and would otherwise stay on the old palette
|
|
# until the user restarts them by hand.
|
|
command -v nomarchy-restart-btop >/dev/null 2>&1 && nomarchy-restart-btop || true
|
|
command -v nomarchy-restart-opencode >/dev/null 2>&1 && nomarchy-restart-opencode || true
|
|
|
|
# Sync palette into Obsidian vaults (no-op when the user has no Obsidian
|
|
# config or no obsidian.css template in the active theme).
|
|
command -v nomarchy-theme-set-obsidian >/dev/null 2>&1 && nomarchy-theme-set-obsidian || true
|
|
|
|
# Reload the wallpaper — its ExecStart path is stable (~/.config/nomarchy/current/background)
|
|
# so sd-switch does not detect a unit change when only the symlink target moves.
|
|
systemctl --user restart nomarchy-wallpaper.service 2>/dev/null || true
|
|
|
|
nomarchy-hook theme-set "$THEME_NAME"
|