{"id":391,"date":"2011-01-28T00:30:38","date_gmt":"2011-10-30T05:51:50","guid":{"rendered":"http:\/\/kraftek.com\/blog\/random-wallpaper-in-gnome\/"},"modified":"2011-01-28T00:30:38","modified_gmt":"2011-10-30T05:51:50","slug":"random-wallpaper-in-gnome","status":"publish","type":"post","link":"\/blog\/index.php\/random-wallpaper-in-gnome\/","title":{"rendered":"random wallpaper in gnome"},"content":{"rendered":"<p>Say you want a random Gnome wallpaper from google each 60 seconds, but if your machine is not connected, just take<br \/>\nthe backdrop from a local directory ~\/Desktop\/backdrops. you can put up a couple of scripts to do this, the main one<br \/>\nwould be \/scripts\/changewall.ksh<\/p>\n<p><em>#!\/bin\/bash<\/em><br \/>\n<em>mkdir -p \/tmp\/wallpapers<\/em><\/p>\n<p><em>E=`ps -ef | grep -i changewall | grep -i $USER | grep -iv grep | wc -l`<\/em><br \/>\n<em>if [ $E -gt 2 ];then<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0echo &#8220;wallpaper changer already running for $USER&#8221;<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0exit 1<\/em><br \/>\n<em>fi<\/em><\/p>\n<p><em>i=120<\/em><br \/>\n<em>while true;do<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0i=`cat \/scripts\/time.txt`<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0rm -fR \/tmp\/wallpapers\/*<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0RANGE=10<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0number=$RANDOM<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0let &#8220;number %= $RANGE&#8221;<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0number=$(($number))<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0ping -w 10 -c 2 www.google.com &gt; \/dev\/null 2&gt;&amp;1<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0R=$?<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0if [ $R -eq 0 ]\u00a0 &amp;&amp; [ $number -lt 9 ];then<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\/scripts\/wallpaper.ksh &gt; \/dev\/null 2&gt;&amp;1<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0F=`ls \/tmp\/wallpapers`<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0N=`echo $F | wc -c`<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if [ $N -gt 1 ];then<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0gconftool-2 -t string -s \/desktop\/gnome\/background\/picture_filename &#8220;\/tmp\/wallpapers\/$F&#8221;<\/em><br \/>\n<em>#\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0cp &#8220;\/tmp\/wallpapers\/$F&#8221; $HOME\/Desktop\/backdrops\/<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0else<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0cd $HOME\/Desktop\/backdrops<\/em><br \/>\n<em>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ls -1 *.jpg | head -n`expr $RANDOM % `ls -1 *.jpg | wc -l&#8220; | tail -n1 | echo `pwd`\/`xargs` | gconftool-2 -t string -s \/desktop\/gnome\/background\/picture_filename &#8220;`xargs`&#8221;<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0fi<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0else<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0cd $HOME\/Desktop\/backdrops\u00a0\u00a0 \u00a0<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ls -1 *.jpg | head -n`expr $RANDOM % `ls -1 *.jpg | wc -l&#8220; | tail -n1 | echo `pwd`\/`xargs` | gconftool-2 -t string -s \/desktop\/gnome\/background\/picture_filename &#8220;`xargs`&#8221;<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0fi<\/em><br \/>\n<em>\u00a0\u00a0 \u00a0sleep $i<\/em><br \/>\n<em>done<\/em><\/p>\n<p>Then you would need the support script, to get images from google according to a random word that comes<br \/>\nfrom \/scripts\/wallpaper-subjects.txt program: \/scripts\/wallpaper.ksh<\/p>\n<p><em>#!\/bin\/ksh<\/em><br \/>\n<em>cat \/scripts\/wallpaper-subjects.txt | head -n`expr $RANDOM % `cat \/scripts\/wallpaper-subjects.txt | wc -l&#8220; | tail -n1 &gt; \/tmp\/subject<\/em><br \/>\n<em>QUERY=`cat \/tmp\/subject | sed &#8216;s\/ \/%20\/g&#8217;`<\/em><br \/>\n<em>RANGE=10<\/em><br \/>\n<em>number=$RANDOM<\/em><br \/>\n<em>let &#8220;number %= $RANGE&#8221;<\/em><br \/>\n<em>number=$(($number + 1))<\/em><em><\/em><br \/>\n<em>IMG=`curl -m 10 -A &#8220;Mozilla\/3.0 (compatible; AvantGo 3.2)&#8221; &#8220;http:\/\/images.google.com\/images?as_q=${QUERY}&amp;as_filetype=jpg&amp;biw=1680&amp;bih=1024&amp;safe=active&amp;as_st=y&amp;tbs=isch:1,itp:photo,islt:2mp,isz:l,ift:jpg&#8221; 2&gt;\/dev\/null |sed -e &#8216;s\/&gt;\/&gt;n\/g&#8217; | awk &#8216;{s=substr($0,index($0,&#8221;http&#8221;),index($0,&#8221;jpg&#8221;));print substr(s,1,index(s,&#8221;.jpg&#8221;)+3)}&#8217; | grep jpg |egrep -v &#8216;starkeith|gstatic|scaredmonkeys|tripod|flickr&#8217;|sed &#8216;s\/2520\/20\/g&#8217; | head -$number | tail -1`<\/em><\/p>\n<p><em>mkdir -p \/tmp\/wallpapers<\/em><br \/>\n<em>cd \/tmp\/wallpapers<\/em><br \/>\n<em>wget &#8211;timeout=10 $IMG<\/em><\/p>\n<p>you can add \/scripts\/changewall.ksh to your autostart stuff in gnome, going to system &#8211;&gt; preferences &#8211;&gt;<br \/>\nstartup applications<br \/>\nENJOY!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Say you want a random Gnome wallpaper from google each 60 seconds, but if your machine is not connected, just take the backdrop from a local directory ~\/Desktop\/backdrops. you can put up a couple of scripts to do this, the main one would be \/scripts\/changewall.ksh #!\/bin\/bash mkdir -p \/tmp\/wallpapers E=`ps -ef | grep -i changewall [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":0,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}