refactor: migrate to template-based theme system, clean up old per-theme configs
- Remove per-theme app configs (alacritty, foot, ghostty, hyprland, hyprlock, mako, rofi, swayosd, tmux, walker, waybar, etc.) now handled by default/themed/ templates - Update omarchy scripts (bg-next, list, set) for new template flow - Update configs: bootstrap, nvim, rofi, tmux, mako - Tweak installers (02-install-base.sh, btop, desktop, goose, nvim, obsidian, theme, tmux) - Remove obsolete hyprland-rofi-* and hyprland-walker-* scripts - Update neovim.lua across remaining themes
This commit is contained in:
+57
-60
@@ -1,77 +1,74 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy-theme-set: Set a theme, specified by its name.
|
||||
# Usage: omarchy-theme-set <theme-name>
|
||||
# omarchy:summary=Apply an Omarchy theme
|
||||
# omarchy:args=<theme-name>
|
||||
# omarchy:examples=omarchy theme list | omarchy theme set "Tokyo Night"
|
||||
|
||||
if [[ -z "$1" && "$1" != "CNCLD" ]]; then
|
||||
echo "Usage: omarchy-theme-set <theme-name>" >&2
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Usage: omarchy-theme-set <theme-name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
THEMES_DIR="$HOME/.local/share/themes"
|
||||
CURRENT_THEME_DIR="${THEMES_DIR}/current/theme"
|
||||
CURRENT_THEME_PATH="$HOME/.config/omarchy/current/theme"
|
||||
NEXT_THEME_PATH="$HOME/.config/omarchy/current/next-theme"
|
||||
USER_THEMES_PATH="$HOME/.config/omarchy/themes"
|
||||
OMARCHY_THEMES_PATH="${DOTFILES_DIR}/themes"
|
||||
|
||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||
THEME_PATH="$THEMES_DIR/available/$THEME_NAME"
|
||||
|
||||
base_theme_dir=$(dirname "$CURRENT_THEME_DIR")
|
||||
if [[ ! -d "$base_theme_dir" ]]; then
|
||||
mkdir -p $base_theme_dir
|
||||
if [[ ! -d $OMARCHY_THEMES_PATH/$THEME_NAME ]] && [[ ! -d $USER_THEMES_PATH/$THEME_NAME ]]; then
|
||||
echo "Theme '$THEME_NAME' does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the theme entered exists
|
||||
if [[ ! -d "$THEME_PATH" ]]; then
|
||||
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR" >&2
|
||||
exit 2
|
||||
# Setup clean next theme directory (for atomic theme config swapping)
|
||||
rm -rf "$NEXT_THEME_PATH"
|
||||
mkdir -p "$NEXT_THEME_PATH"
|
||||
|
||||
# Copy official theme first, then overlay user customizations on top
|
||||
cp -r "$OMARCHY_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
|
||||
cp -r "$USER_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
|
||||
|
||||
# Generate colors.toml from alacritty.toml if theme is missing colors.toml
|
||||
if [[ ! -f $NEXT_THEME_PATH/colors.toml && -f $NEXT_THEME_PATH/alacritty.toml ]]; then
|
||||
omarchy-theme-colors-from-alacritty "$NEXT_THEME_PATH"
|
||||
fi
|
||||
|
||||
# Update theme symlinks
|
||||
ln -nsf "$THEME_PATH" "$CURRENT_THEME_DIR"
|
||||
# Generate dynamic configs
|
||||
omarchy-theme-set-templates
|
||||
|
||||
# Change gnome modes
|
||||
if [[ -f "$CURRENT_THEME_DIR/light.mode" ]]; then
|
||||
gsettings set org.gnome.desktop.interface color-scheme "prefer-light"
|
||||
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita"
|
||||
else
|
||||
gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
|
||||
gsettings set org.gnome.desktop.interface gtk-theme "Adwaita-dark"
|
||||
# Swap next theme in as current
|
||||
rm -rf "$CURRENT_THEME_PATH"
|
||||
mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH"
|
||||
|
||||
# Store theme name for reference
|
||||
echo "$THEME_NAME" >"$HOME/.config/omarchy/current/theme.name"
|
||||
|
||||
# Change background with theme
|
||||
if [[ $OMARCHY_THEME_SKIP_BACKGROUND != "1" ]]; then
|
||||
omarchy-theme-bg-next
|
||||
fi
|
||||
|
||||
# Change gnome icon theme color
|
||||
if [[ -f "$CURRENT_THEME_DIR/icons.theme" ]]; then
|
||||
gsettings set org.gnome.desktop.interface icon-theme "$(<$CURRENT_THEME_DIR/icons.theme)"
|
||||
else
|
||||
gsettings set org.gnome.desktop.interface icon-theme "Yaru-blue"
|
||||
fi
|
||||
# # Restart components to apply new theme
|
||||
# if pgrep -x waybar >/dev/null; then
|
||||
# omarchy-restart-waybar
|
||||
# fi
|
||||
# omarchy-restart-swayosd
|
||||
# omarchy-restart-terminal
|
||||
omarchy-restart-hyprctl
|
||||
omarchy-restart-btop
|
||||
# omarchy-restart-opencode
|
||||
omarchy-restart-mako
|
||||
omarchy-restart-tmux
|
||||
# omarchy-restart-helix
|
||||
|
||||
# Change Chromium colors
|
||||
if command -v chromium &>/dev/null; then
|
||||
if [[ -f "$CURRENT_THEME_DIR/light.mode" ]]; then
|
||||
chromium --no-startup-window --set-color-scheme="light"
|
||||
else
|
||||
chromium --no-startup-window --set-color-scheme="dark"
|
||||
fi
|
||||
|
||||
if [[ -f "$CURRENT_THEME_DIR/chromium.theme" ]]; then
|
||||
chromium --no-startup-window --set-theme-color="$(<$CURRENT_THEME_DIR/chromium.theme)"
|
||||
else
|
||||
# Use a default, neutral grey if theme doesn't have a color
|
||||
chromium --no-startup-window --set-theme-color="28,32,39"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CURRENT_THEME_DIR/ghostty" ]]; then
|
||||
touch "$CURRENT_THEME_DIR/ghostty"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CURRENT_THEME_DIR/tmux" ]]; then
|
||||
touch "$CURRENT_THEME_DIR/tmux"
|
||||
fi
|
||||
|
||||
omarchy-theme-bg-next
|
||||
|
||||
# Restart components to apply new theme
|
||||
pkill -SIGUSR2 btop
|
||||
makoctl reload
|
||||
hyprctl reload
|
||||
# Change app-specific themes
|
||||
omarchy-theme-set-foot
|
||||
omarchy-theme-set-gnome
|
||||
omarchy-theme-set-browser
|
||||
#omarchy-theme-set-vscode
|
||||
omarchy-theme-set-obsidian
|
||||
#omarchy-theme-set-keyboard
|
||||
|
||||
# Call hook on theme set
|
||||
omarchy-hook theme-set "$THEME_NAME" >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user