Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I'm very new to Linux's world, so I would ask to forgive me for every stupid or too simple thing I will ask now.

I installed Elementary OS from their website just yesterday. I wanted to change my wallpaper automatically with Bing's wallpaper, so I found on Google a script that downloads from Bing's servers the image... That's good, it works (I see the images downloaded inside the folder).

The problem is that it doesn't always change the wallpaper. Sometimes yes, sometimes not. I don't understand really when and why. It seems that it happens when the downloaded image is not new. Sorry for my bad english, what I mean is that I put this script starting on boot with the tool given with Elementary OS, and if I turn on my pc >1 times per day, (and Bing's image change one time per day) the other times I just get everything black as wallpaper. Here is the part of the code that changes wallpaper, maybe it is there the problem:


# $bing is needed to form the fully qualified URL for
# the Bing pic of the day

# $xmlURL is needed to get the xml data from which
# the relative URL for the Bing pic of the day is extracted
# The mkt parameter determines which Bing market you would like to
# obtain your images from.
# Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA.
# The idx parameter determines where to start from. 0 is the current day,
# 1 the previous day, etc.

# $saveDir is used to set the location where Bing pics of the day
# are stored.  $HOME holds the path of the current user's home directory

# Create saveDir if it does not already exist
mkdir -p $saveDir

# Set picture options
# Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned

# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"

# The file extension for the Bing pic

# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL

# Form the URL for the desired pic resolution
desiredPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$desiredPicRes$picExt

# Form the URL for the default pic resolution
defaultPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<url>(.*)</url>" | cut -d ">" -f 2 | cut -d "<" -f 1)

# $picName contains the filename of the Bing pic of the day

# Attempt to download the desired image resolution. If it doesn't
# exist then download the default image resolution
if wget --quiet --spider "$desiredPicURL"

    # Set picName to the desired picName
    # Download the Bing pic of the day at desired resolution
    curl -s -o $saveDir$picName $desiredPicURL
    # Set picName to the default picName
    # Download the Bing pic of the day at default resolution
    curl -s -o $saveDir$picName $defaultPicURL

# Set the GNOME3 wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$saveDir$picName'"'

# Set the GNOME 3 wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts

 # Remove pictures older than 30 days
find $saveDir -atime 30 -delete

# Exit the script
share|improve this question

migrated from Oct 7 '13 at 17:00

This question came from our site for Ubuntu users and developers.

What is the script that downloads the image? Also, I'm not sure that script will work on Elementary OS. –  Seth Oct 7 '13 at 16:14
Just a note, it's easier to use feh than muck about in gsettings. –  hbdgaf Oct 7 '13 at 16:19
@Seth The script to download images works because I see the images into the folder... –  misiMe Oct 7 '13 at 16:42
Do you have curl installed? Upon testing, the script appears to work for me. Of course, I haven't done any continued testing yet. –  Seth Oct 7 '13 at 17:51
I don't know if I have curl installed, how do I know it? –  misiMe Oct 8 '13 at 15:14

1 Answer 1

up vote 3 down vote accepted

Rather than mess with dconf you can use feh --bg-max to set the background image fairly easily.

$ feh --bg-max <image>

I use this type of script to rotate the background image every 15 minutes, for example:

while true; do
  find ~/.wallpaper -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
    shuf -n1 -z | xargs -0 feh --bg-max
    sleep 15m

The above also makes use of the little used but handy shuf command for randomizing a list of files.

share|improve this answer
So are you saying that it could just be dconf acting funny? –  Seth Oct 7 '13 at 20:38
@Seth - yeah that's what it seems like to me as well. –  slm Oct 7 '13 at 22:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.