Files
Nomarchy/bin/nomarchy-theme-set-vscode
Bernardo Magri cfd5e4bb65 feat(core): migrate system state to unified declarative JSON
- Consolidate all configuration toggles (suspend, idle, waybar, etc.) into ~/.config/home-manager/state.json
- Introduce nomarchy.toggles and nomarchy.hyprland options in Nix
- Inject toggle states into all bin/ scripts via environment variables
- Update toggle scripts to mutate JSON and trigger background rebuilds
- Add a migration script to transition legacy flag files to the new format
2026-04-04 10:11:09 +01:00

40 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Sync Nomarchy theme to VS Code, VSCodium, and Cursor
VS_CODE_THEME="$HOME/.config/nomarchy/current/theme/vscode.json"
set_theme() {
local editor_cmd="$1"
local settings_path="$2"
nomarchy-cmd-present "$editor_cmd" && [[ $NOMARCHY_TOGGLE_SKIP_VSCODE_THEME != "true" ]] || return 0
if [[ -f $VS_CODE_THEME ]]; then
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
extension=$(jq -r '.extension' "$VS_CODE_THEME")
if [[ -n $extension ]] && ! "$editor_cmd" --list-extensions | grep -Fxq "$extension"; then
"$editor_cmd" --install-extension "$extension" >/dev/null
fi
mkdir -p "$(dirname "$settings_path")"
[[ -f $settings_path ]] || printf '{\n}\n' >"$settings_path"
if ! grep -q '"workbench.colorTheme"' "$settings_path"; then
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\ "workbench.colorTheme": "",/}' "$settings_path"
fi
sed -i --follow-symlinks -E \
"s/(\"workbench.colorTheme\"[[:space:]]*:[[:space:]]*\")[^\"]*(\")/\1$theme_name\2/" \
"$settings_path"
elif [[ -f $settings_path ]]; then
sed -i --follow-symlinks -E 's/\"workbench\.colorTheme\"[[:space:]]*:[^,}]*,?//' "$settings_path"
fi
}
set_theme "code" "$HOME/.config/Code/User/settings.json"
set_theme "code-insiders" "$HOME/.config/Code - Insiders/User/settings.json"
set_theme "codium" "$HOME/.config/VSCodium/User/settings.json"
set_theme "cursor" "$HOME/.config/Cursor/User/settings.json"