#!/bin/bash
########################################################
#               Mate Random Background                 #   
# Simple gui to change backgrounds in timed intervals  # 
#------------------------------------------------------#
#       © 2022 WTFPL   lxgator@gmail.com     	       #
########################################################

ICON='/usr/share/icons/hicolor/48x48/apps/random-background.png'
notify-send -t 6000 -i $ICON "Random Background" "Intervals set at 2 hours"
while [ $? = 0 ]; 
do
CONF=`cat $HOME/.random-background/pid | awk 'NR==1{print $0}'`
kill -9 $CONF  2>/dev/null
pkill -SIGKILL random10 2>/dev/null
pkill -SIGKILL random30 2>/dev/null
pkill -SIGKILL random60 2>/dev/null
sleep 3
pgrep -n "sleep" > $HOME/.random-background/pid
exit 0
done&
while true
do
DIR=$HOME/'Wallpapers'
PIC=$(ls $DIR/*.* | shuf -n1)
gsettings set org.mate.background picture-filename "$PIC" 
sleep 120m 
done
