mirror of
https://github.com/LukeHagar/omarchy.git
synced 2025-12-06 04:20:23 +00:00
Theme support for Cursor (#2015)
* Imitating VSCode omarchy-theme-set * Changed VSCode theme setter take arguments to Cursor theme setter could call it. * All omarchy commands are in path --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: @adelplace
This commit is contained in:
@@ -30,9 +30,10 @@ hyprctl reload
|
|||||||
pkill -SIGUSR2 btop
|
pkill -SIGUSR2 btop
|
||||||
makoctl reload
|
makoctl reload
|
||||||
|
|
||||||
# Change gnome, browser, vscode themes
|
# Change gnome, browser, vscode, cursor themes
|
||||||
omarchy-theme-set-terminal
|
omarchy-theme-set-terminal
|
||||||
omarchy-theme-set-gnome
|
omarchy-theme-set-gnome
|
||||||
omarchy-theme-set-eza
|
omarchy-theme-set-eza
|
||||||
omarchy-theme-set-browser
|
omarchy-theme-set-browser
|
||||||
omarchy-theme-set-vscode
|
omarchy-theme-set-vscode
|
||||||
|
omarchy-theme-set-cursor
|
||||||
|
|||||||
4
bin/omarchy-theme-set-cursor
Executable file
4
bin/omarchy-theme-set-cursor
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Call the VSCode theme setter with Cursor-specific parameters
|
||||||
|
omarchy-theme-set-vscode cursor "$HOME/.config/Cursor/User/settings.json" "$HOME/.local/state/omarchy/toggles/skip-cursor-theme-changes" Cursor
|
||||||
@@ -3,43 +3,47 @@
|
|||||||
# Note: We cannot use `jq` to update settings.json because it’s JSONC (allows comments),
|
# Note: We cannot use `jq` to update settings.json because it’s JSONC (allows comments),
|
||||||
# which jq doesn’t support.
|
# which jq doesn’t support.
|
||||||
|
|
||||||
VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json"
|
# Parameters: EDITOR_CMD SETTINGS_PATH SKIP_FLAG EDITOR_NAME
|
||||||
VS_CODE_SETTINGS="$HOME/.config/Code/User/settings.json"
|
EDITOR_CMD="${1:-code}"
|
||||||
VS_CODE_SKIP_FLAG="$HOME/.local/state/omarchy/toggles/skip-vscode-theme-changes"
|
SETTINGS_PATH="${2:-$HOME/.config/Code/User/settings.json}"
|
||||||
|
SKIP_FLAG="${3:-$HOME/.local/state/omarchy/toggles/skip-vscode-theme-changes}"
|
||||||
|
EDITOR_NAME="${4:-VS Code}"
|
||||||
|
|
||||||
if omarchy-cmd-present code && [[ ! -f "$VS_CODE_SKIP_FLAG" ]]; then
|
VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json"
|
||||||
|
|
||||||
|
if omarchy-cmd-present "$EDITOR_CMD" && [[ ! -f "$SKIP_FLAG" ]]; then
|
||||||
if [[ -f "$VS_CODE_THEME" ]]; then
|
if [[ -f "$VS_CODE_THEME" ]]; then
|
||||||
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
theme_name=$(jq -r '.name' "$VS_CODE_THEME")
|
||||||
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
extension=$(jq -r '.extension' "$VS_CODE_THEME")
|
||||||
|
|
||||||
# Install VS Code theme extension
|
# Install $EDITOR_NAME theme extension
|
||||||
if [[ -n "$extension" ]] && ! code --list-extensions | grep -Fxq "$extension"; then
|
if [[ -n "$extension" ]] && ! "$EDITOR_CMD" --list-extensions | grep -Fxq "$extension"; then
|
||||||
notify-send " Installing VS Code theme for $theme_name"
|
notify-send " Installing $EDITOR_NAME theme for $theme_name"
|
||||||
code --install-extension "$extension" >/dev/null
|
"$EDITOR_CMD" --install-extension "$extension" >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create config file if there isn't already one
|
# Create config file if there isn't already one
|
||||||
mkdir -p "$(dirname "$VS_CODE_SETTINGS")"
|
mkdir -p "$(dirname "$SETTINGS_PATH")"
|
||||||
if [[ ! -f "$VS_CODE_SETTINGS" ]]; then
|
if [[ ! -f "$SETTINGS_PATH" ]]; then
|
||||||
printf '{\n}\n' > "$VS_CODE_SETTINGS"
|
printf '{\n}\n' > "$SETTINGS_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a `workbench.colorTheme` entry in settings.
|
# Create a `workbench.colorTheme` entry in settings.
|
||||||
if ! grep -q '"workbench.colorTheme"' "$VS_CODE_SETTINGS"; then
|
if ! grep -q '"workbench.colorTheme"' "$SETTINGS_PATH"; then
|
||||||
# Insert `"workbench.colorTheme": "",` immediately after the first `{`
|
# Insert `"workbench.colorTheme": "",` immediately after the first `{`
|
||||||
# Use sed's first-match range (0,/{/) to only replace the first `{`
|
# Use sed's first-match range (0,/{/) to only replace the first `{`
|
||||||
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\
|
sed -i --follow-symlinks -E '0,/\{/{s/\{/{\
|
||||||
"workbench.colorTheme": "",/}' "$VS_CODE_SETTINGS"
|
"workbench.colorTheme": "",/}' "$SETTINGS_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update theme
|
# Update theme
|
||||||
sed -i --follow-symlinks -E \
|
sed -i --follow-symlinks -E \
|
||||||
"s/(\"workbench.colorTheme\"[[:space:]]*:[[:space:]]*\")[^\"]*(\")/\1$theme_name\2/" \
|
"s/(\"workbench.colorTheme\"[[:space:]]*:[[:space:]]*\")[^\"]*(\")/\1$theme_name\2/" \
|
||||||
"$VS_CODE_SETTINGS"
|
"$SETTINGS_PATH"
|
||||||
else
|
else
|
||||||
# Remove theme from settings.json when the theme doesn't have vscode support
|
# Remove theme from settings.json when the theme doesn't have $EDITOR_NAME support
|
||||||
if [[ -f "$VS_CODE_SETTINGS" ]]; then
|
if [[ -f "$SETTINGS_PATH" ]]; then
|
||||||
sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$VS_CODE_SETTINGS"
|
sed -i --follow-symlinks -E '/"workbench\.colorTheme"[[:space:]]*:[^,}]*,?/d' "$SETTINGS_PATH"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user