don't delete wallpaplist + more reporting

This commit is contained in:
n 2018-01-21 23:02:37 +01:00
parent 60d3848f1a
commit 54931a6e4f

View file

@ -1,7 +1,11 @@
#!/bin/bash
Dir="/home/n/img/wallpap/1920x1200/"
wallpaplist="/home/n/.wallpaplist"
#export DISPLAY=:0.0
echo "DISPLAY:$DISPLAY
"
Dir="~/img/wallpap/1920x1200/"
wallpaplist="~/.wallpaplist"
contact="n@tourmentine.com"
if [ ! -d "$Dir" ];
then
@ -14,6 +18,7 @@ then
touch ${wallpaplist}
fi
while true; do
AvailableFiles=`ls -1 ${Dir} | wc -l`
AlreadyViewedFiles=`cat ${wallpaplist} | wc -l`
@ -22,7 +27,8 @@ TotalFiles=`expr $AvailableFiles - $AlreadyViewedFiles`
if [ $TotalFiles -lt 1 ];
then
echo "*** Seems we have displayed all available wallpapers; let's do the time warp...again. ***"
rm -f ${wallpaplist}
echo ""> ${wallpaplist}
echo "" | /usr/bin/mail -s "Seems we have displayed all available wallpapers; let's do the time warp...again." ${contact}
TotalFiles=$AvailableFiles
fi
@ -33,16 +39,27 @@ RandomFile="$( ls -1 ${Dir} | grep -w -v -F -f ${wallpaplist} | head -n $RandomN
if [[ ${RandomFile} == "" ]];
then
echo "*** Oops, something went wrong. erasing cache for security ***"
rm -f ${wallpaplist}
echo ""> ${wallpaplist}
echo "" | /usr/bin/mail -s "Oops, something went wrong. erasing cache for security" ${contact}
exit 1
else
echo "${RandomFile}" >> ${wallpaplist}
fi
if [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] ; then
. ${HOME}/.dbus/session-bus/`ls -rt ${HOME}/.dbus/session-bus/ | tail -1`
export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
fi
#echo "Selected File: $RandomFile"
DISPLAY=:0.0 feh --bg-scale "${Dir%/}/${RandomFile}"
DISPLAY=:0.0 xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${Dir%/}/${RandomFile}"
feh --bg-scale "${Dir%/}/${RandomFile}"
#echo ${DBUS_SESSION_BUS_ADDRESS}
echo "" | /usr/bin/mail -s "New wallpaper: ${RandomFile}" ${contact}
echo "Selected File: $RandomFile"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${Dir%/}/${RandomFile}"
pkill gkrellm && DISPLAY=:0.0 gkrellm
xfconf-query -c xfce4-desktop -v -p /backdrop/screen0/monitor0/last-image -s "${Dir%/}/${RandomFile}"
xfconf-query -c xfce4-desktop -v -p /backdrop/screen0/monitorVGA1/workspace0/last-image -s "${Dir%/}/${RandomFile}"
xfconf-query -c xfce4-desktop -v -p /backdrop/screen0/monitor0/workspace0/last-image -s "${Dir%/}/${RandomFile}"
pkill gkrellm && gkrellm &
# 3 hours
sleep 10800
done