1st script

This commit is contained in:
n 2014-09-13 19:07:42 +02:00
commit 7693d8c729

61
randomwallpaper.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/bash
#export DISPLAY=:0.0
echo "DISPLAY:$DISPLAY
"
Dir="/home/n/img/wallpap/1920x1200/"
wallpaplist="/home/n/.wallpaplist"
if [ ! -d "$Dir" ];
then
echo "${Dir} does not exist"
exit 1
fi
if [ ! -f ${wallpaplist} ];
then
touch ${wallpaplist}
fi
AvailableFiles=`ls -1 ${Dir} | wc -l`
AlreadyViewedFiles=`cat ${wallpaplist} | wc -l`
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}
TotalFiles=$AvailableFiles
fi
RandomNumber=$(( $RANDOM % $TotalFiles ))
test ! $RandomNumber = 0 || RandomNumber=1
RandomFile="$( ls -1 ${Dir} | grep -w -v -F -f ${wallpaplist} | head -n $RandomNumber | tail -n 1)"
if [[ ${RandomFile} == "" ]];
then
echo "*** Oops, something went wrong. erasing cache for security ***"
rm -f ${wallpaplist}
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 ${DBUS_SESSION_BUS_ADDRESS}
#echo "Selected File: $RandomFile"
#DISPLAY=:0.0 feh --bg-scale "${Dir%/}/${RandomFile}"
#feh --bg-scale "${Dir%/}/${RandomFile}"
#DISPLAY=:0.0 xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${Dir%/}/${RandomFile}"
#DISPLAY=:0.0 sudo -u n xfconf-query -c xfce4-desktop -v -p /backdrop/screen0/monitor0/image-path -s ""
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${Dir%/}/${RandomFile}"
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}"
pkill gkrellm && gkrellm
#pkill gkrellm && DISPLAY=:0.0 gkrellm