Files
omarchy/bin/omarchy-theme-next

54 lines
1.5 KiB
Plaintext
Raw Normal View History

2025-06-18 21:17:59 +02:00
#!/bin/bash
THEMES_DIR="$HOME/.config/omarchy/themes/"
2025-06-19 08:10:36 -04:00
CURRENT_THEME_LINK="$HOME/.config/omarchy/current/theme"
2025-06-18 21:17:59 +02:00
THEMES=($(find "$THEMES_DIR" -mindepth 1 | sort))
TOTAL=${#THEMES[@]}
2025-06-18 21:56:22 +02:00
# Get current theme from symlink
if [[ -L "$CURRENT_THEME_LINK" ]]; then
CURRENT_THEME=$(readlink "$CURRENT_THEME_LINK")
2025-06-18 21:17:59 +02:00
else
2025-06-18 21:56:22 +02:00
# Default to first theme if no symlink exists
CURRENT_THEME=${THEMES[0]}
2025-06-18 21:17:59 +02:00
fi
2025-06-18 21:56:22 +02:00
# Find current theme index
INDEX=0
for i in "${!THEMES[@]}"; do
if [[ "${THEMES[$i]}" == "$CURRENT_THEME" ]]; then
INDEX=$i
break
fi
done
# Get next theme (wrap around)
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
NEW_THEME=${THEMES[$NEXT_INDEX]}
2025-06-19 02:39:57 +02:00
NEW_THEME_NAME=$(basename "$NEW_THEME")
2025-06-18 21:56:22 +02:00
2025-06-19 08:10:36 -04:00
# Set current theme
ln -nsf "$HOME/.config/omarchy/backgrounds/$NEW_THEME_NAME" "$HOME/.config/omarchy/current/backgrounds"
ln -nsf "$NEW_THEME" "$HOME/.config/omarchy/current/theme"
2025-06-18 21:45:27 +02:00
# Touch alacritty config to pickup the changed theme
2025-06-19 08:10:36 -04:00
touch "$HOME/.config/alacritty/alacritty.toml"
2025-06-19 15:11:55 +02:00
# Restart for new theme
2025-06-19 08:10:36 -04:00
pkill waybar && setsid waybar
2025-06-19 15:11:55 +02:00
pkill swaync && setsid swaync
2025-06-18 21:17:59 +02:00
2025-06-19 08:26:13 -04:00
# Set new background
ln -nsf $(find "$HOME/.config/omarchy/current/backgrounds/" -type f | head -n 1) "$HOME/.config/omarchy/current/background"
pkill -x swaybg && setsid swaybg -i "$HOME/.config/omarchy/current/background" -m fill
2025-06-21 20:10:16 -04:00
# Wait for swaync to get started properly again
while ! pgrep -x swaync >/dev/null; do
sleep 0.05
done
sleep 0.5
# Notify of the new theme
notify-send "Theme changed to $NEW_THEME_NAME" -t 2000 -e