The older way of doing this, with gconftool-2 doesn’t seem to work anymore in GNOME 3 – used to be something like: gconftool-2 –type string –set /desktop/gnome/background/picture_filename “/full/path/to/file.png”.
However, there is still possible to change the background image, by using the gsettings tool instead. You will need the libglib2.0-bin package, which is probably already installed on your system. To change the background, use a command like the following:
Where you replace $PATH_TO_FILE with the full path to the file, e.g.:
Here’s a small script for automatically changing the wallpaper every 60 seconds (just change the sleep 60 value to another value, in seconds). Although not very elegant, it will do the job (please suggest something better here):
This script will automatically cycle between all the .jpg wallpapers in the directory /usr/share/backgrounds/. Just replace it with another directory if needed.
i find this script better and easy to figure out though it’s longer: start below this line —
#!/usr/bin/perl -w
use strict;
use warnings;
### Start CONFIG
my $searchPath = ‘/home/username/photos-directory/’;
my $switchTime = 600; # Time is in seconds
### END CONFIG
# bgotd– background of the day
#
# A super simple script which randomly picks a jpg/JPG/jpeg/JPEG photo to place as your
# Gnome desktop.
#
# Written by Michael Moore, Nov. 2007
# This work is hereby placed in the public domain
my @photos = `find $searchPath -type f | grep [jJ][pP][eE]*[gG]`;
chomp(@photos);
my $photo;
while(1)
{
$photo = $photos[rand($#photos)];
`gsettings set org.gnome.desktop.background picture-uri “file:///$photo”`;
sleep($switchTime);
}
—end above this line —————–modify the “my$searchPath” then make it executable—————–
why not a cronjob?
Type “crontab -e”, then add the following line:
* * * * * /path/to/this/script.py
Save and exit; it’ll install this new cronjob. Then your script will be called once in every minute.
Damn, now my script won’t work in both gnome2 and gnome3 with the same command.
By the way,
for i in $(echo /usr/share/backgrounds/*.jpg)
instead of just
for i in /usr/share/backgrounds/*.jpg
is not only longer and pointless but also problematic if a background has spaces in its name.
(Also, there are so many – instead of – – here…)
gsettings set org.gnome.desktop.background picture-uri file:////home/user/image.jpg
Other commands not working. I used above one.
It makes background black !!! Any solution ? I m using CentOS 7
Perfect!