#!/bin/bash
########################################################
#               Mate Random Background                 #   
# Simple gui to change backgrounds in timed intervals  # 
#------------------------------------------------------#
#       © 2022 WTFPL   lxgator@gmail.com     	       #
########################################################
# Changes the current desktop background
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
pkill -SIGKILL random120 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" &
pkill -SIGKILL change 2>/dev/null
sleep 120m
done
