Friday, May 28, 2010

Automatic wallpaper changer script for Linux

I always want linux to compete with windows. In windows 7 , wallpaper changes automatically .So i wrote this script .

#!/bin/bash

#author IRFAN NASEEF P
#       irfan@nitc.ac.in
# please report bugs to the author

# Usually the background pics are stored in /usr/share/backgrounds

cd /usr/share/backgrounds

num=`ls | wc -l`
#echo $num
choice=`expr $RANDOM % $num`
#echo "choice is $choice"
filename=`eval ls | head -$choice  | tail -1`
#echo "That is $filename"

if [ -f $filename ]
then
gconftool-2  --type string  --set /desktop/gnome/background/picture_filename "/usr/share/backgrounds/$filename"
else
  #echo "$filename is not a file"
  exit 1
fi

exit 0


#####

You can run this script in crontab for automatic changing of wallpaper.
Or you can put it as a nautilus-script .

No comments:

Post a Comment