#!/bin/bash
set -euo pipefail

directory=~/Pictures/wallpapers
wallpaper=~/.cache/images/wallpaper.png
monitor=$(hyprctl monitors | grep Monitor | awk '{print $2}')

if [ -d "$directory" ]; then
  #random_background=$(ls $directory | shuf -n 1)
  random_background=$(find $directory -type f | shuf -n 1)
  wallpaper $random_background
  hyprctl hyprpaper unload all
  hyprctl hyprpaper preload $wallpaper
  hyprctl hyprpaper wallpaper "$monitor, $wallpaper"
fi
