#!/bin/bash

directory="/home/pablusha/wallpapers"

files=()
while IFS= read -r -d $'\0' file; do
    if [ -f "$file" ]; then
        files+=("$file")
    fi
done < <(find "$directory" -maxdepth 1 -type f -print0)

if [ ${#files[@]} -eq 0 ]; then
    exit 1
fi

random_file="${files[RANDOM % ${#files[@]}]}"
swww img $random_file --transition-type wipe --transition-fps 60 --transition-angle 30 --transition-duration 1
matugen image $random_file -t scheme-fruit-salad
notify-send "wallpaper changed" $random_file
