mirror of
https://github.com/basecamp/omarchy.git
synced 2025-07-27 12:19:24 +00:00
Rely fully on the symlinks
This commit is contained in:
@ -1,27 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
THEMES_DIR="$HOME/.config/omarchy/themes/"
|
||||
NEXT_THEME_FILE="$HOME/.cache/next_theme_index"
|
||||
CURRENT_THEME_LINK="$HOME/.config/omarchy/current-theme"
|
||||
|
||||
THEMES=($(find "$THEMES_DIR" -mindepth 1 | sort))
|
||||
TOTAL=${#THEMES[@]}
|
||||
|
||||
if [[ ! -f "$NEXT_THEME_FILE" ]]; then
|
||||
INDEX=0
|
||||
# Get current theme from symlink
|
||||
if [[ -L "$CURRENT_THEME_LINK" ]]; then
|
||||
CURRENT_THEME=$(readlink "$CURRENT_THEME_LINK")
|
||||
else
|
||||
INDEX=$(<"$NEXT_THEME_FILE")
|
||||
# Default to first theme if no symlink exists
|
||||
CURRENT_THEME=${THEMES[0]}
|
||||
fi
|
||||
|
||||
# Set new theme
|
||||
NEW_THEME=${THEMES[$INDEX]}
|
||||
ln -nsf $NEW_THEME ~/.config/omarchy/current-theme
|
||||
# Find current theme index
|
||||
INDEX=0
|
||||
for i in "${!THEMES[@]}"; do
|
||||
if [[ "${THEMES[$i]}" == "$CURRENT_THEME" ]]; then
|
||||
INDEX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Save next index (wrap around)
|
||||
echo "$(((INDEX + 1) % TOTAL))" >"$NEXT_THEME_FILE"
|
||||
# Get next theme (wrap around)
|
||||
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
|
||||
NEW_THEME=${THEMES[$NEXT_INDEX]}
|
||||
|
||||
# Set new theme
|
||||
ln -nsf $NEW_THEME ~/.config/omarchy/current-theme
|
||||
|
||||
# Install theme backgrounds
|
||||
source ~/.config/omarchy/current-theme/backgrounds.sh
|
||||
ln -nsf ~/.config/omarchy/backgrounds/catpuccin ~/.config/omarchy/current-backgrounds
|
||||
THEME_NAME=$(basename "$NEW_THEME")
|
||||
ln -nsf ~/.config/omarchy/backgrounds/$THEME_NAME ~/.config/omarchy/current-backgrounds
|
||||
|
||||
# Touch alacritty config to pickup the changed theme
|
||||
touch ~/.config/alacritty/alacritty.toml
|
||||
|
Reference in New Issue
Block a user