Set BING Background as your Desktop Wallpaper in GNOME


BING comes up with a beautiful background everyday. I thought why not set this background as my desktop wallpaper. But it would be a cumbersome task to set it manually. So I searched (Googled, BINGed) for some script which will do this for me. I found BING Downloader which does this task on Windows. I could not find any such script for GNOME. So, I thought of writing one.

I wrote a script which when executed automatically sets the GNOME wallpaper as BING background of the day. This is a PHP script. To execute this script you need to have php installed on your system. You can install php in Ubuntu as

sudo apt-get install php5 php5-cli

Now you are all set to download this script. Download Link: http://www.spsneo.com/scripts/bing_wallpaper.tar.gz

Download this file, extract the script file. Now you can run the script from terminal :
php bing_wallpaper.php

And your wallpaper is set. You can run this script daily from your terminal or you can set a cron job for the same or you can set up an icon in your gnome panel for this script.

I will keep updating this script. And I am also planning to write the same script in python. So check back again if you dont want to install php on your system.

Send your feedbacks and suggestions.

Update 1: I have modified the script to work with http proxy. Just assure that the environment variable http_proxy is properly set.

Update 2: Modified the script to keep the image centered on the desktop with black background. Try it out.

Loading Facebook Comments ...

11 thoughts on “Set BING Background as your Desktop Wallpaper in GNOME

  1. orjanv

    after uppacking the tar.gz, i would recommend to run this on the .php file:

    sed ‘s/centered/zoom/g’ -i bing_wallpaper.php

    in order to set the wallpaper fullscreen, since the images from bing.com is pretty small compared to the monitors used today. Even on netbooks.

  2. Karfield

    I think it’s no need to use php-cli. I write a bash script, it works fine too;)
    Here’s my code:

    #!/bin/bash
    #
    # Write by Karfield
    #
    # Free to use it!)
    #
    BING=http://www.bing.com
    TMPFILE=/tmp/bing.html
    WALLPAPER=/home/$USER/Downloads/bing.jpg
    echo “Try to get the BING page…”
    wget -q $BING -O $TMPFILE
    ! [ -e $TMPFILE ] && exit;
    URL=$BING$(sed -n “s/\(.*\)g_img={url\:’\([0-9a-Z?=%_-\\/\\.]*\)’\,id\(.*\)/\2/p” < $TMPFILE)
    echo "Get the picture's URL = "$URL
    rm $TMPFILE
    mv $WALLPAPER{,-old}
    echo "Download the wallpaper… "
    wget -q $URL -O $WALLPAPER
    if [ -e $WALLPAPER ]; then
    echo "We got it, set the background…"
    gconftool-2 –type string –set /desktop/gnome/background/picture_filename $WALLPAPER
    gconftool-2 –type string –set /desktop/gnome/background/picture_options zoom
    gconftool-2 –type string –set /desktop/gnome/background/primary_color black
    fi

    You can save the code as update_bing_wallpaper.sh, don't forget to change the file mode as "u+x". And run it to change your background.

  3. Pingback: Set Bing images as your wallpaper « The Ubuntu Incident

  4. Viswanatha Reddy

    Hi Karfield,
    I tried to run your script, but it gave me the following error
    sed: -e expression #1, char 1: unknown command: `?’
    This might be complaining about these lines
    ! [ -e $TMPFILE ] && exit;
    URL=$BING$(sed -n “s/\(.*\)g_img={url\:’\([0-9a-Z?=%_-\\/\\.]*\)’\,id\(.*\)/\2/p” < $TMPFILE)

    Then, I saw a bing.jpg file in Downloads. But it was corrupted.
    I'm using ubuntu 12.04. Can you please help me with that ?

  5. Lemontree123

    I have successfully run the script with following changes (will give at the end of post)! The image is downloaded good to the location mention in “/home/$USER/Downloads/bing.jpg”.
    NOTE: I need to run this script in Terminal mode!
    For the unknown character, you need to change the character ” to corresponding quote mark (the one next to my Enter button in keyboard) in the sed command.

    Here is my full script:
    BING=http://www.bing.com
    TMPFILE=/home/$USER/Downloads/tmp/bing.html
    WALLPAPER=/home/$USER/Pictures/bing.jpg
    echo “Try to get the BING page…”
    echo $TMPFILE
    wget -q $BING -O $TMPFILE
    ! [ -e $TMPFILE ] && exit;
    URL=$BING$(sed -n “s/\(.*\)g_img={url\:\([0-9a-Z?=%_-\\/\\.]*\)\,id\(.*\)/\2/p” < $TMPFILE | sed "s/[\']//g;" )
    echo "Get the picture's URL = "$URL
    rm $TMPFILE
    mv $WALLPAPER{,-old}
    echo "Download the wallpaper… "
    wget -q $URL -O $WALLPAPER
    if [ -e $WALLPAPER ]; then
    echo "We got it, set the background…"
    echo $WALLPAPER
    gsettings set org.gnome.desktop.background picture-uri 'file://'$WALLPAPER
    gsettings set org.gnome.desktop.background picture-options 'zoom'
    fi

Leave a Reply