<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Bash Script to Randomly Change Gnome Background</title>
	<atom:link href="http://www.djlosch.com/dlo/bash-script-to-randomly-change-gnome-background/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.djlosch.com/dlo/bash-script-to-randomly-change-gnome-background/</link>
	<description>David Loschiavo</description>
	<pubDate>Thu, 09 Sep 2010 18:53:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: David Castillo</title>
		<link>http://www.djlosch.com/dlo/bash-script-to-randomly-change-gnome-background/#comment-369</link>
		<dc:creator>David Castillo</dc:creator>
		<pubDate>Sun, 12 Jul 2009 23:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.djlosch.com/dlo/?p=24#comment-369</guid>
		<description>I was having problems with $RANDOM var in bash scripts, It was returning a null value, I've fixed the problem using the unix time instead of $RANDOM also I've avoided the usage of 'expr'

here's my code:

#!/bin/bash
# script: change_backgrounds.sh - bash version
# version 2007.3.7
# description: randomly replace gnome background with one from a directory
# credits: David Loschiavo [http://www.djlosch.com], Steven Van Ingelgem
# license: GPL
# UPDATED By: David Castillo Sanchez [mailto:davcs86@gmail.com]
# version 2009.7.12
# Notes: Compatible with Ubuntu Jaunty Jackalope, Linux 2.6.28-13 generic

bg_path=/home/ilusmbax/desktopimages
extensions="jpg png gif jpeg JPEG JPG GIF PNG"
temp_bg_list=/tmp/bg_change_li2

rm -f $temp_bg_list

for extension in $extensions
do
	find $bg_path -iregex ".*.$extension" &#62;&#62; "$temp_bg_list"
done

cnt=`wc -l "$temp_bg_list" &#124; cut -f1 -d" "`
con=`date +%S`
all_bgs=$((con % cnt));
selected_bg=`head -n$all_bgs "$temp_bg_list" &#124; tail -n1`

logger "Changed desktop to: $selected_bg"

gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$selected_bg"
exit 0</description>
		<content:encoded><![CDATA[<p>I was having problems with $RANDOM var in bash scripts, It was returning a null value, I&#8217;ve fixed the problem using the unix time instead of $RANDOM also I&#8217;ve avoided the usage of &#8216;expr&#8217;</p>
<p>here&#8217;s my code:</p>
<p>#!/bin/bash<br />
# script: change_backgrounds.sh - bash version<br />
# version 2007.3.7<br />
# description: randomly replace gnome background with one from a directory<br />
# credits: David Loschiavo [http://www.djlosch.com], Steven Van Ingelgem<br />
# license: GPL<br />
# UPDATED By: David Castillo Sanchez [mailto:davcs86@gmail.com]<br />
# version 2009.7.12<br />
# Notes: Compatible with Ubuntu Jaunty Jackalope, Linux 2.6.28-13 generic</p>
<p>bg_path=/home/ilusmbax/desktopimages<br />
extensions=&#8221;jpg png gif jpeg JPEG JPG GIF PNG&#8221;<br />
temp_bg_list=/tmp/bg_change_li2</p>
<p>rm -f $temp_bg_list</p>
<p>for extension in $extensions<br />
do<br />
	find $bg_path -iregex &#8220;.*.$extension&#8221; &gt;&gt; &#8220;$temp_bg_list&#8221;<br />
done</p>
<p>cnt=`wc -l &#8220;$temp_bg_list&#8221; | cut -f1 -d&#8221; &#8220;`<br />
con=`date +%S`<br />
all_bgs=$((con % cnt));<br />
selected_bg=`head -n$all_bgs &#8220;$temp_bg_list&#8221; | tail -n1`</p>
<p>logger &#8220;Changed desktop to: $selected_bg&#8221;</p>
<p>gconftool-2 -t string -s /desktop/gnome/background/picture_filename &#8220;$selected_bg&#8221;<br />
exit 0</p>
]]></content:encoded>
	</item>
</channel>
</rss>
