[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Autorn of program on KDE login?



On Sun, Jan 23, 2005 at 09:19:38AM -0500, stan wrote:
> I'm trying to convert a setup from Gnome 1.4 to something current. So far
> I'm leaning in the direction of KDE, as it seems more customizable than
> the current flavor of Gnome (which BTW sunrises me).
> 
> In any case, I have a perl script that picks a random image to use for a
> desktop background. In Gnome 1.4, I'm able to configure this program to be
> run automatically at startup.
> 
> So far, I have not found a way to do this in KDE. Is there some way I can
> do this?

On my desktop, I have a cron job run as my user that grabs a new picture
or wallpaper every 5 minutes.  I've tested it with fluxbox, xfce4, and
Gnome.  Gnome's gconf interface will let you change the location of the
wallpaper, as long as the filename is different than the last time.

Jeremy
#!/bin/bash

# Export what display we're using
export DISPLAY=:0.0

# A temporary location
tmp_loc=/home/jeremy/tmp

# A list of all possible wallpaper
bg_list=$tmp_loc/list

# The actual wallpaper path & name
wall_base=background.jpg
wallpaper=$tmp_loc/$wall_base
wallpaper2=$tmp_loc/2$wall_base

# The directories of where we should find wallpaper
bg_loc="/home/jeremy/pub/pictures /home/jeremy/pub/wallpaper"

# Check to see if the bg_list is more than 10 min old
if [ $(( `date +%s -r $bg_list &> /dev/null` + 630 )) -lt  `date +%s` ]
then
	#echo "File is out of date and needs to be updated!"
	find $bg_loc | grep -E "*.jpg" > $bg_list
fi

# Grab a random line number from $bg_list
rand=$(( $RANDOM % `cat $bg_list | wc -l` ))

# Grab the filename of the random line number
rand_file=`cat $bg_list | tail -n $rand | head -n 1`

# Copy the wallpaper to the tmp location
cp "$rand_file" "$tmp_loc"

# Move the random file to our know filename
mv "$tmp_loc/`basename "$rand_file"`" "$tmp_loc/$wall_base"


# Find what directory the picture came from
bg_dir=`dirname "$rand_file"`
bg_dir=`basename "$bg_dir"`

# Add the directory into the picture
/usr/bin/convert -font "Bitstream Vera Sans" -fill navy -draw "text 150,150 \"$bg_dir\"" -pointsize 72 "$wallpaper" "$wallpaper"

# if fluxbox/blackbox
fbpid=`pidof fluxbox`

if [ $fbpid ] 
then
	#echo "Found Fluxbox: $fbpid"
	fbsetbg -a "$wallpaper"
fi

# if gnome
gnpid=`pidof gnome-session`
if [ $gnpid ]
then
	# With Gnome/gconf, the filename must be named differently each time,
	# or else the change doesn't hold.  Instead of using the converted 
	# graphic, I just grab the random file.
	#echo "Found Gnome: $gnpid"
	gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$rand_file"
	
fi

# if xfce4
xfpid=`pidof xfdesktop`
if [ $xfpid ]
then
	#echo "Found XFCE4: $xfpid"
	xfdesktop
fi

Reply to: