mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Automatically change VS Code theme along with Omarchy themes (#800)
* Automatically change VS Code theme along with Omarchy themes * Create a way to skip vscode auto-theming * Make theme setting resilient to different states of the settings.json * Improve setting and removing theme and notify when waiting on install * Explain what we're doing * Extract dedicated bin for vscode theme change --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
@@ -60,6 +60,9 @@ fi
|
||||
# Trigger alacritty config reload
|
||||
touch "$HOME/.config/alacritty/alacritty.toml"
|
||||
|
||||
# Update vscode theme
|
||||
omarchy-theme-set-vscode
|
||||
|
||||
# Restart components to apply new theme
|
||||
pkill -SIGUSR2 btop
|
||||
omarchy-restart-waybar
|
||||
|
||||
25
bin/omarchy-theme-set-vscode
Executable file
25
bin/omarchy-theme-set-vscode
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/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
|
||||
# Install VS Code theme extension
|
||||
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
||||
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
|
||||
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
||||
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
|
||||
4
themes/catppuccin-latte/vscode.json
Normal file
4
themes/catppuccin-latte/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Catppuccin Latte",
|
||||
"extension": "catppuccin.catppuccin-vsc"
|
||||
}
|
||||
4
themes/catppuccin/vscode.json
Normal file
4
themes/catppuccin/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Catppuccin Macchiato",
|
||||
"extension": "catppuccin.catppuccin-vsc"
|
||||
}
|
||||
4
themes/everforest/vscode.json
Normal file
4
themes/everforest/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Everforest Dark",
|
||||
"extension": "sainnhe.everforest"
|
||||
}
|
||||
4
themes/gruvbox/vscode.json
Normal file
4
themes/gruvbox/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Gruvbox Dark Medium",
|
||||
"extension": "jdinhlife.gruvbox"
|
||||
}
|
||||
4
themes/kanagawa/vscode.json
Normal file
4
themes/kanagawa/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Kanagawa",
|
||||
"extension": "qufiwefefwoyn.kanagawa"
|
||||
}
|
||||
4
themes/matte-black/vscode.json
Normal file
4
themes/matte-black/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Matte Black Theme",
|
||||
"extension": "cleanthemes.matte-black-theme"
|
||||
}
|
||||
4
themes/nord/vscode.json
Normal file
4
themes/nord/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Nord",
|
||||
"extension": "arcticicestudio.nord-visual-studio-code"
|
||||
}
|
||||
4
themes/osaka-jade/vscode.json
Normal file
4
themes/osaka-jade/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Ocean Green: Dark",
|
||||
"extension": "jovejonovski.ocean-green"
|
||||
}
|
||||
4
themes/ristretto/vscode.json
Normal file
4
themes/ristretto/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Monokai Pro (Filter Ristretto)",
|
||||
"extension": "monokai.theme-monokai-pro-vscode"
|
||||
}
|
||||
4
themes/rose-pine/vscode.json
Normal file
4
themes/rose-pine/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Rosé Pine Dawn",
|
||||
"extension": "mvllow.rose-pine"
|
||||
}
|
||||
4
themes/tokyo-night/vscode.json
Normal file
4
themes/tokyo-night/vscode.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Tokyo Night",
|
||||
"extension": "enkia.tokyo-night"
|
||||
}
|
||||
Reference in New Issue
Block a user