#!/bin/bash

SCRIPTS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPTS_DIR/config.sh

directory=$WALLPAPER_DIR
monitor=`hyprctl monitors | grep Monitor | awk '{print $2}'`

if [ -d "$directory" ]; then
    background=$(ls $directory/$1*)
    hyprctl hyprpaper unload all
    hyprctl hyprpaper preload $background
    hyprctl hyprpaper wallpaper "$monitor, $background"
fi

exit
