To understand the intricacies of the various options available, its worth just having a little dig around in the source-code to see what happens with each option. I'll try my best to put this is simply as possible, but with the caveat - you need to enjoy a bit of mathematics!
Lets grab the source-code:
apt-get source gnome-desktop3
cd gnome-desktop*
cd libgnome-desktop
Now open the following source-module with your favourite text editor:
gedit gnome-bg.c
There are two key functions to examine:
get_scaled_pixbuf
switch (placement) {
case G_DESKTOP_BACKGROUND_STYLE_SPANNED:
new = pixbuf_scale_to_fit (pixbuf, width, height);
break;
case G_DESKTOP_BACKGROUND_STYLE_ZOOM:
new = pixbuf_scale_to_min (pixbuf, width, height);
break;
case G_DESKTOP_BACKGROUND_STYLE_STRETCHED:
new = gdk_pixbuf_scale_simple (pixbuf, width, height,
GDK_INTERP_BILINEAR);
break;
case G_DESKTOP_BACKGROUND_STYLE_SCALED:
new = pixbuf_scale_to_fit (pixbuf, width, height);
break;
case G_DESKTOP_BACKGROUND_STYLE_CENTERED:
case G_DESKTOP_BACKGROUND_STYLE_WALLPAPER:
default:
new = pixbuf_clip_to_fit (pixbuf, width, height);
break;
}
and the function:
draw_image_area
switch (bg->placement) {
case G_DESKTOP_BACKGROUND_STYLE_WALLPAPER:
pixbuf_tile (scaled, dest);
break;
case G_DESKTOP_BACKGROUND_STYLE_ZOOM:
case G_DESKTOP_BACKGROUND_STYLE_CENTERED:
case G_DESKTOP_BACKGROUND_STYLE_STRETCHED:
case G_DESKTOP_BACKGROUND_STYLE_SCALED:
pixbuf_blend (scaled, dest, 0, 0, w, h, x + area->x, y + area->y, 1.0);
break;
case G_DESKTOP_BACKGROUND_STYLE_SPANNED:
pixbuf_blend (scaled, dest, 0, 0, w, h, x, y, 1.0);
break;
default:
g_assert_not_reached ();
break;
}
- Lets first look at the option SPAN
This is described by the case option G_DESKTOP_BACKGROUND_STYLE_SPANNED
The wallpaper (pixbuf) is first scaled to the area to be filled (pixbuf_scale_to_fit) i.e. take the original wallpaper and expand its width and height to match the area.
It uses the following algorithm to expand:
factor = MIN (max_width / src_width, max_height / src_height);
new_width = floor (src_width * factor + 0.5);
new_height = floor (src_height * factor + 0.5);
src_ is the wallpaper dimension width or height, whereas max_ is the area dimension width or height
Quite a complicated algorithm as you can see, but basically it tries to see what is the minimum dimension that needs to be expanded before scaling both dimensions linearly by the same factor it has calculated.
This area is the combined area of your monitor or monitors.
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the whole area.
- Lets look at the option SCALE
This is described by the case option G_DESKTOP_BACKGROUND_STYLE_SCALED
As you can see in the source code, its very similar to SPAN. It uses the same algorithm to scale the picture as SPAN.
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the view port area i.e. not the combined area of all monitors, but the area of each monitor individually.
- Lets look at the option Zoom
This is described by the case option G_DESKTOP_BACKGROUND_ZOOM
The wallpaper (pixbuf) is first scaled to the area to be filled (pixbuf_scale_to_min) i.e. take the original wallpaper and expand its width and height to match the area.
It uses the following algorithm to expand:
factor = MAX (min_width / src_width, min_height / src_height);
new_width = floor (src_width * factor + 0.5);
new_height = floor (src_height * factor + 0.5);
src_ is the wallpaper dimension width or height, whereas max_ is the area dimension width or height*
Notice the subtle difference than the previous two options - it calculates the maximum dimension that needs to be expanded before scaling both dimensions linearly by the same factor it has calculated.
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the view port area i.e. not the combined area of all monitors, but the area of each monitor individually.
- Lets look at the option STRETCH
This is described by the case option G_DESKTOP_BACKGROUND_STRETCHED
The wallpaper (pixbuf) is expanded both width-wise and height-wise to the area - thus you can get a distortion if your wallpaper is not the exact dimensions of the wallpaper
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the view port area i.e. not the combined area of all monitors, but the area of each monitor individually.
- Lets look at the option CENTER
This is described by the case option G_DESKTOP_BACKGROUND_CENTRED
The wallpaper (pixbuf) is actually clipped to size if its too large to fit the area i.e. the the width is reduced to the area width and the height is reduced to the area height.
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the view port area i.e. not the combined area of all monitors, but the area of each monitor individually. The resulting image is then drawn into the center of the overall area of the monitor.
- Lets look at the option TILE
This is described by the case option G_DESKTOP_BACKGROUND_WALLPAPER
The wallpaper (pixbuf) is similarly clipped as the Center option.
The resulting wallpaper (pixbuf) is then blended with the desktop background colour for the view port area i.e. not the combined area of all monitors, but the area of each monitor individually. The resulting image is copied repeatedly starting in one corner filling the overall area with each image i.e. tiled width-wise and height-wise.
Edit (2019): Nitrogen is no longer maintained. Nitrogen doesn't fully work on newer Ubuntu distros.
To install it, run the following command in terminal:
sudo apt-get install nitrogen
Because nitrogen
doesn't have a desktop file by default when is installed, you need to run the following command from terminal to start it:
nitrogen
How to use it?
In it's Preferences, add your wallpaper folder, then at the bottom [...] select Screen 1, 2, etc., to set a different wallpaper for each monitor:
To be able to set a different wallpaper for each monitor, you must
disable the file manager from handling the desktop. This means you'll
no longer have folders on the desktop.
In GNOME / Unity, install GNOME Tweak Tool:
sudo apt-get install gnome-tweak-tool
Then open GNOME Tweak Tool and on the Desktop section, set Icons on Desktop (previously Have file manager handle the desktop) to OFF.
And finally, to have the wallpapers restored each time you log in, add the following command:
nitrogen --restore
to your Startup Applications.
Source: UBUNTU MULTI-MONITOR TWEAKS (FULL SCREEN FLASH FIXES, SPAN WALLPAPER ACROSS MONITORS, MORE)
Best Answer
You may try using (GNOME) Tweaks. You may install it by running
Launch Tweaks and go to Desktop section and select "Centered" in Adjustment under Background:
To fill the rest of your background with while colour, run
(Or follow the advanced option of my answer here: Change background color to pitch black , for white you'll have to use
#FFFFFF
instead of#000000
).