#!/bin/bash

sec=60
_setWallpaperRandomly() {
    waypaper --random
    echo ":: Next wallpaper in $sec seconds..."
    sleep $sec
    _setWallpaperRandomly
}

if [ ! -f ~/.cache/hyprland/wallpaper-automation ] ;then
    touch ~/.cache/hyprland/wallpaper-automation
    echo ":: Start wallpaper automation script"
    notify-send "Wallpaper automation process started" "Wallpaper will be changed every $sec seconds."
    _setWallpaperRandomly
else
    rm ~/.cache/hyprland/wallpaper-automation
    notify-send "Wallpaper automation process stopped."
    echo ":: Wallpaper automation script process $wp stopped"
    wp=$(pgrep -f wallpaper-automation.sh)
    kill -KILL $wp
fi
