Files
omarchy/bin/omarchy-theme-next

52 lines
1.4 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 -maxdepth 1 | sort))
2025-06-18 21:17:59 +02:00
TOTAL=${#THEMES[@]}
2025-06-18 21:56:22 +02:00
# Get current theme from symlink
if [[ -L "$CURRENT_THEME_LINK" ]]; then
CURRENT_THEME=$(realpath "$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=$(realpath "${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
THEMES[$i]=$(realpath "${THEMES[$i]}")
2025-06-18 21:56:22 +02:00
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
pkill -SIGUSR2 waybar
2025-06-22 20:48:38 -04:00
makoctl reload
2025-06-22 20:35:48 -04:00
hyprctl reload
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"
2025-06-22 20:48:38 -04:00
pkill -x swaybg
setsid swaybg -i "$HOME/.config/omarchy/current/background" -m fill &
2025-06-21 20:10:16 -04:00
# Notify of the new theme
2025-06-22 20:48:38 -04:00
notify-send "Theme changed to $NEW_THEME_NAME" -t 2000