From 7693d8c72912b60d20692f184f8994aef2986297 Mon Sep 17 00:00:00 2001 From: n Date: Sat, 13 Sep 2014 19:07:42 +0200 Subject: [PATCH] 1st script --- randomwallpaper.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 randomwallpaper.sh diff --git a/randomwallpaper.sh b/randomwallpaper.sh new file mode 100755 index 0000000..f06ed99 --- /dev/null +++ b/randomwallpaper.sh @@ -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