#!/usr/bin/env bash

# Finds wallpaper candidates from fixed roots passed as separate arguments.
# Keeping paths as argv values avoids shell interpolation for names containing
# quotes, spaces, or other shell syntax.

set -euo pipefail

find "$@" -maxdepth 2 -type f \
    \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' \) \
    -printf '%T@ %p\n' 2>/dev/null \
    | sort -rn \
    | cut -d' ' -f2- \
    | awk 'NR <= 60'
