View Single Post
grog's Avatar
Posts: 546 | Thanked: 85 times | Joined on Feb 2008 @ Winnipeg, Canada
#27
Originally Posted by qole View Post
I don't think rndback needs to be run as user, so you can run it as root without problem.
Unfortunately it does need to be run as 'user'. If run as root I get the error 'cannot connect to x display'.

Another thing I noticed that when I ran the script via cron I'd always get the same small set of images rather than a sampling of my entire pictures folder. The reason for this of course is qole's usage of 'date +%S%S' for a random number in the rndback script. This prints out the current seconds (twice), which is great except when being run via cron at almost the same second each time!

So I came up with this updated version of qole's rndback script. Works for me. See what you think.

Code:
#Pull in the config, if possible...
[ -f /home/user/.wallpaper ] && . /home/user/.wallpaper

#These come from the config file... If not, fall back on defaults
[ "x$IMGTYPE" != x ] || IMGTYPE="jpg\|png\|gif"
[ "x$IMGDIRS" != x ] || IMGDIRS="/home/user/MyDocs/.images /usr/share/backgrounds"
find $IMGDIRS | grep -i "\.\($IMGTYPE\)" > /tmp/wplist.txt
TOTIMGS=`wc -l < /tmp/wplist.txt`

# pick out a random line from the list
RNDIMG=`awk -v tot=$TOTIMGS 'BEGIN {srand();printline=(rand()*10000%tot)+1;printline=substr(printline,1,index(printline,".")-1)} NR==printline' /tmp/wplist.txt`

echo changing to $RNDIMG
setback "$RNDIMG"
HTH
__________________
GROG!
N900 | ZAGG Body Armour | 16Gb A-DATA micro-sd
N810 | 2 x Patriot 8gb mini-SD | Boxwave Crystal Clear SS | Black Aluminum case | OTG dongle
N800 | 2 x 8gb OCX SD | Boxwave Anti-glare SS | PDAir book-style case
Holux M-1200 bluetooth GPS | iGo 4-row bluetooth keyboard | Linksys USB 10/100 ethernet | Plantronics Voyager 855 BT Headset
 

The Following User Says Thank You to grog For This Useful Post: