2025-06-09 11:59:21 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Cycles through the background images available
|
|
|
|
|
2025-06-18 21:17:59 +02:00
|
|
|
BACKGROUNDS_DIR="$HOME/.config/omarchy/current-backgrounds/"
|
2025-06-09 11:59:21 +02:00
|
|
|
NEXT_BACKGROUND_FILE="$HOME/.cache/next_background_index"
|
|
|
|
|
|
|
|
BACKGROUNDS=($(find "$BACKGROUNDS_DIR" -type f | sort))
|
|
|
|
TOTAL=${#BACKGROUNDS[@]}
|
|
|
|
|
|
|
|
if [[ ! -f "$NEXT_BACKGROUND_FILE" ]]; then
|
|
|
|
INDEX=0
|
|
|
|
else
|
|
|
|
INDEX=$(<"$NEXT_BACKGROUND_FILE")
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Save next index (wrap around)
|
2025-06-18 21:17:59 +02:00
|
|
|
echo "$(((INDEX + 1) % TOTAL))" >"$NEXT_BACKGROUND_FILE"
|
2025-06-09 11:59:21 +02:00
|
|
|
|
|
|
|
# Launch swaybg
|
|
|
|
pkill -x swaybg
|
|
|
|
setsid swaybg -i "${BACKGROUNDS[$INDEX]}" -m fill >/dev/null 2>&1 &
|