Files
omarchy/bin/omarchy-theme-bg-next

38 lines
1015 B
Plaintext
Raw Normal View History

2025-06-09 11:59:21 +02:00
#!/bin/bash
# Cycles through the background images available
2025-06-19 08:10:36 -04:00
BACKGROUNDS_DIR="$HOME/.config/omarchy/current/backgrounds/"
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
2025-06-09 11:59:21 +02:00
mapfile -d '' -t BACKGROUNDS < <(find "$BACKGROUNDS_DIR" -type f -print0 | sort -z)
2025-06-09 11:59:21 +02:00
TOTAL=${#BACKGROUNDS[@]}
2025-06-18 22:00:47 +02:00
# Get current background from symlink
if [[ -L "$CURRENT_BACKGROUND_LINK" ]]; then
CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
2025-06-09 11:59:21 +02:00
else
2025-06-18 22:00:47 +02:00
# Default to first background if no symlink exists
CURRENT_BACKGROUND="${BACKGROUNDS[0]}"
2025-06-09 11:59:21 +02:00
fi
2025-06-18 22:00:47 +02:00
# Find current background index
INDEX=0
for i in "${!BACKGROUNDS[@]}"; do
if [[ "${BACKGROUNDS[$i]}" == "$CURRENT_BACKGROUND" ]]; then
INDEX=$i
break
fi
done
# Get next background (wrap around)
NEXT_INDEX=$(((INDEX + 1) % TOTAL))
NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
2025-06-18 22:00:47 +02:00
# Set new background symlink
ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
2025-06-09 11:59:21 +02:00
2025-06-19 08:26:08 -04:00
# Relaunch swaybg
2025-06-09 11:59:21 +02:00
pkill -x swaybg
2025-06-26 10:21:37 -07:00
setsid swaybg -i "$NEW_BACKGROUND" -m fill >/dev/null 2>&2 &