#!/bin/sh

dir="$HOME/Pictures/Wallpapers/"
list=$(find "$dir" -type f -or -type l \
    -name "*.png" \
    -or -name "*.jpg" \
    -or -name "*.jpeg" \
    -or -name "*.PNG" \
    -or -name "*.JPG" \
    -or -name "*.JPEG" \
    -or -name "*.gif")
options=""

# Destroy running swaybg process
pkill swaybg

for i in $(wlr-randr | grep -E '".*\(.*\)"' | awk '{print $1}')
do
  choice=$(echo "${list}" | shuf -n 1)
  options="${options}--output ${i} --image ${choice} --mode fill "
done

exec swaybg ${options}
