From d3304c4a8894a440350b34a8d78992cd550f90ba Mon Sep 17 00:00:00 2001 From: Omar Skalli Date: Mon, 15 Sep 2025 09:20:02 -0700 Subject: [PATCH] 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 --- bin/omarchy-theme-set | 3 +++ bin/omarchy-theme-set-vscode | 25 +++++++++++++++++++++++++ themes/catppuccin-latte/vscode.json | 4 ++++ themes/catppuccin/vscode.json | 4 ++++ themes/everforest/vscode.json | 4 ++++ themes/gruvbox/vscode.json | 4 ++++ themes/kanagawa/vscode.json | 4 ++++ themes/matte-black/vscode.json | 4 ++++ themes/nord/vscode.json | 4 ++++ themes/osaka-jade/vscode.json | 4 ++++ themes/ristretto/vscode.json | 4 ++++ themes/rose-pine/vscode.json | 4 ++++ themes/tokyo-night/vscode.json | 4 ++++ 13 files changed, 72 insertions(+) create mode 100755 bin/omarchy-theme-set-vscode create mode 100644 themes/catppuccin-latte/vscode.json create mode 100644 themes/catppuccin/vscode.json create mode 100644 themes/everforest/vscode.json create mode 100644 themes/gruvbox/vscode.json create mode 100644 themes/kanagawa/vscode.json create mode 100644 themes/matte-black/vscode.json create mode 100644 themes/nord/vscode.json create mode 100644 themes/osaka-jade/vscode.json create mode 100644 themes/ristretto/vscode.json create mode 100644 themes/rose-pine/vscode.json create mode 100644 themes/tokyo-night/vscode.json diff --git a/bin/omarchy-theme-set b/bin/omarchy-theme-set index 8685a6f..80cd291 100755 --- a/bin/omarchy-theme-set +++ b/bin/omarchy-theme-set @@ -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 diff --git a/bin/omarchy-theme-set-vscode b/bin/omarchy-theme-set-vscode new file mode 100755 index 0000000..5ceb3f5 --- /dev/null +++ b/bin/omarchy-theme-set-vscode @@ -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 diff --git a/themes/catppuccin-latte/vscode.json b/themes/catppuccin-latte/vscode.json new file mode 100644 index 0000000..98d1113 --- /dev/null +++ b/themes/catppuccin-latte/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Catppuccin Latte", + "extension": "catppuccin.catppuccin-vsc" +} diff --git a/themes/catppuccin/vscode.json b/themes/catppuccin/vscode.json new file mode 100644 index 0000000..26e1188 --- /dev/null +++ b/themes/catppuccin/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Catppuccin Macchiato", + "extension": "catppuccin.catppuccin-vsc" +} diff --git a/themes/everforest/vscode.json b/themes/everforest/vscode.json new file mode 100644 index 0000000..02b107d --- /dev/null +++ b/themes/everforest/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Everforest Dark", + "extension": "sainnhe.everforest" +} diff --git a/themes/gruvbox/vscode.json b/themes/gruvbox/vscode.json new file mode 100644 index 0000000..e75a9b9 --- /dev/null +++ b/themes/gruvbox/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Gruvbox Dark Medium", + "extension": "jdinhlife.gruvbox" +} diff --git a/themes/kanagawa/vscode.json b/themes/kanagawa/vscode.json new file mode 100644 index 0000000..91f7539 --- /dev/null +++ b/themes/kanagawa/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Kanagawa", + "extension": "qufiwefefwoyn.kanagawa" +} diff --git a/themes/matte-black/vscode.json b/themes/matte-black/vscode.json new file mode 100644 index 0000000..719d366 --- /dev/null +++ b/themes/matte-black/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Matte Black Theme", + "extension": "cleanthemes.matte-black-theme" +} diff --git a/themes/nord/vscode.json b/themes/nord/vscode.json new file mode 100644 index 0000000..897b8ba --- /dev/null +++ b/themes/nord/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Nord", + "extension": "arcticicestudio.nord-visual-studio-code" +} diff --git a/themes/osaka-jade/vscode.json b/themes/osaka-jade/vscode.json new file mode 100644 index 0000000..efe2d63 --- /dev/null +++ b/themes/osaka-jade/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Ocean Green: Dark", + "extension": "jovejonovski.ocean-green" +} diff --git a/themes/ristretto/vscode.json b/themes/ristretto/vscode.json new file mode 100644 index 0000000..41a587e --- /dev/null +++ b/themes/ristretto/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Monokai Pro (Filter Ristretto)", + "extension": "monokai.theme-monokai-pro-vscode" +} diff --git a/themes/rose-pine/vscode.json b/themes/rose-pine/vscode.json new file mode 100644 index 0000000..07e0050 --- /dev/null +++ b/themes/rose-pine/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Rosé Pine Dawn", + "extension": "mvllow.rose-pine" +} diff --git a/themes/tokyo-night/vscode.json b/themes/tokyo-night/vscode.json new file mode 100644 index 0000000..89af98c --- /dev/null +++ b/themes/tokyo-night/vscode.json @@ -0,0 +1,4 @@ +{ + "name": "Tokyo Night", + "extension": "enkia.tokyo-night" +}