#!/bin/bash

# Default path
DEFAULT_PATH="/home/umbra/Pictures/"

# List of files to cycle through
FILES=("arizona.jpg" "5571686-2493485633.jpg" "545499.jpg" "581f4483539c0a718fa96ccfe018dde1675cfb88.jpeg" "1920x1080.png" "jgha3z774qz41-3676514128.jpg" "wp4281966-1189243419.jpg" "wp9382189-landscape-illustration-wallpapers.jpg" "FoolMoonNight.jpg")

# File to track the last processed index
INDEX_FILE="$HOME/.swww-cycle-index"

# If index file exists, read the last processed index
if [[ -f "$INDEX_FILE" ]]; then
    read LAST_INDEX < "$INDEX_FILE"
else
    LAST_INDEX=0
fi

# Calculate the next index to process
NEXT_INDEX=$(( (LAST_INDEX + 1) % ${#FILES[@]} ))

# Update the index file with the next index
echo "$NEXT_INDEX" > "$INDEX_FILE"

# Get the next file to process
NEXT_FILE="${FILES[NEXT_INDEX]}"

# Form the full path by concatenating default path and next file
FULL_PATH="${DEFAULT_PATH}${NEXT_FILE}"

# Execute the command with the full path
swww img "$FULL_PATH"

