Ok, on these forums I found very silly ways to change your desktop picture randomly at intervals. Some involved installing programs, daemons, or using python(!) to achieve this simple task. Here is the solution, using plain old methods.
First, a shell script is used. This will do most of the work - basically the windows equivalent is a batch file, except this is advanced. This is the code, pretty intuitive:
Code:
#!/bin/bash
# Set your folder with the pics
picsfolder="/media/documents/Desktops/"
# Go to your folder with the pics
cd $picsfolder
# Create an array of the files
files=(./*/*.jpg)
# Get the size of the array
N=${#files[@]}
# Select a random number between this range
((N=RANDOM%N))
# Get the name of this file
# a bit overly complicated. basically it takes the Nth string from files ${files[$N]}, and then removes the first two letters which is the "./" at the beginning
randomfile=`echo ${files[$N]} | cut --characters="1 2" --complement`
# start of gconftool command and set the desktop
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
Note that the last command is what does the work - it calls a program to set this "registry key" thing to point to your new file. Now to actually make this code do stuff, we have to save it to a file. In a terminal do this:
Code:
execute: gksu gedit
paste the above code
save to: /bin/changewallpaper.sh
exit the gedit
execute: gksu chmod +x /bin/changewallpaper.sh
now we have a script to change the wallpaper. we have also made the file executable (+x). you can run it in your terminal by typing changewallpaper.sh
Now to make it run every so often, you use cron - a schecheduling program that most linux distributions has. In a terminal do this:
Code:
execute: crontab -e
add an extra line: */15 * * * * changewallpaper.sh
add an extra line: @reboot changewallpaper.sh
press: control+x
press: y
press: enter
what that means is that every 15 minutes and every time the computer starts, it will run changewallpaper.sh
modify that 15 if you want.
check http://mkaz.com/ref/unix_cron.html for more cron info
Notes
Here are some other suggestions, and some seem better
http://www.ubuntuforums.org/showpost...6&postcount=14
http://www.ubuntuforums.org/showpost...4&postcount=13
Troubleshooting
Copied from http://www.ubuntuforums.org/showpost...8&postcount=16
If your wallpapers do not change, just add them to the gnome wallpaper manager. After it seems like the wallpapers change
Quoted from pt123:
I get the error:
scripts/changeWallpaper.sh: 10: arith: syntax error: "RANDOM%921+1"
pt123's solution:
I found why it wont work when called in a terminal from another forum. if you're running ubuntu you may find /bin/sh is symlinked to dash and not bash. sometimes you find weird errors occurring because of that.
So the solution was:
Code:
rm /bin/sh
then
ln -s /bin/bash /bin/sh
Bookmarks