mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Make an atomic swap of the theme directories
This commit is contained in:
@@ -7,6 +7,7 @@ fi
|
|||||||
|
|
||||||
THEMES_DIR="$HOME/.config/omarchy/themes/"
|
THEMES_DIR="$HOME/.config/omarchy/themes/"
|
||||||
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
||||||
|
NEXT_THEME_DIR="$HOME/.config/omarchy/current/next-theme"
|
||||||
|
|
||||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||||
@@ -16,16 +17,20 @@ if [[ ! -d "$THEME_PATH" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup clean theme directory
|
# Setup clean next theme directory
|
||||||
rm -rf "$CURRENT_THEME_DIR"
|
rm -rf "$NEXT_THEME_DIR"
|
||||||
mkdir -p "$CURRENT_THEME_DIR"
|
mkdir -p "$NEXT_THEME_DIR"
|
||||||
|
|
||||||
# Copy static configs
|
# Copy static configs
|
||||||
cp -r "$THEME_PATH/"* "$CURRENT_THEME_DIR/" 2>/dev/null
|
cp -r "$THEME_PATH/"* "$NEXT_THEME_DIR/" 2>/dev/null
|
||||||
|
|
||||||
# Generate dynamic configs
|
# Generate dynamic configs
|
||||||
omarchy-theme-set-templates
|
omarchy-theme-set-templates
|
||||||
|
|
||||||
|
# Swap next theme in as current
|
||||||
|
rm -rf "$CURRENT_THEME_DIR"
|
||||||
|
mv "$NEXT_THEME_DIR" "$CURRENT_THEME_DIR"
|
||||||
|
|
||||||
# Change background with theme
|
# Change background with theme
|
||||||
omarchy-theme-bg-next
|
omarchy-theme-bg-next
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TEMPLATES_DIR="$OMARCHY_PATH/themes/templates.d"
|
TEMPLATES_DIR="$OMARCHY_PATH/themes/templates.d"
|
||||||
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
NEXT_THEME_DIR="$HOME/.config/omarchy/current/next-theme"
|
||||||
COLORS_FILE="$CURRENT_THEME_DIR/colors.toml"
|
COLORS_FILE="$NEXT_THEME_DIR/colors.toml"
|
||||||
|
|
||||||
# Only generate dynamic templates for themes with a colors.toml definition
|
# Only generate dynamic templates for themes with a colors.toml definition
|
||||||
if [[ -f $COLORS_FILE ]]; then
|
if [[ -f $COLORS_FILE ]]; then
|
||||||
@@ -14,7 +14,7 @@ if [[ -f $COLORS_FILE ]]; then
|
|||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for tpl in "$TEMPLATES_DIR"/*.tpl; do
|
for tpl in "$TEMPLATES_DIR"/*.tpl; do
|
||||||
filename=$(basename "$tpl" .tpl)
|
filename=$(basename "$tpl" .tpl)
|
||||||
output_path="$CURRENT_THEME_DIR/$filename"
|
output_path="$NEXT_THEME_DIR/$filename"
|
||||||
|
|
||||||
# Don't overwrite configs already exists in the output directory (copied from theme specific folder)
|
# Don't overwrite configs already exists in the output directory (copied from theme specific folder)
|
||||||
if [[ ! -f $output_path ]]; then
|
if [[ ! -f $output_path ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user