mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 12:37:46 +00:00
27 lines
1.1 KiB
Bash
Executable File
27 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json"
|
|
VS_CODE_SETTINGS="$HOME/.config/Code/User/settings.json"
|
|
VS_CODE_SKIP_FLAG="$HOME/.local/state/omarchy/toggles/skip-vscode-theme-changes"
|
|
|
|
if omarchy-cmd-present code && [[ ! -f "$VS_CODE_SKIP_FLAG" ]]; then
|
|
if [[ -f "$VS_CODE_THEME" ]]; then
|
|
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
|
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
|
|
|
# Install VS Code theme extension
|
|
if [[ -n "$extension" ]] && ! code --list-extensions | grep -Fxq "$extension"; then
|
|
notify-send " Installing VS Code theme for $theme_name"
|
|
code --install-extension "$extension" >/dev/null
|
|
fi
|
|
|
|
# Update theme in settings.json
|
|
jq -n --arg t "$theme_name" '(input? // {}) | .["workbench.colorTheme"] = $t' "$VS_CODE_SETTINGS" >"${VS_CODE_SETTINGS}.new"
|
|
else
|
|
# Remove theme from settings.json when the theme doesn't have vscode support
|
|
jq 'del(.["workbench.colorTheme"])' "$VS_CODE_SETTINGS" >"${VS_CODE_SETTINGS}.new"
|
|
fi
|
|
|
|
mv "${VS_CODE_SETTINGS}.new" "$VS_CODE_SETTINGS"
|
|
fi
|