Different wallpapers on multiple monitors

The trick

It seems impossible to separately set wallpapers for the main screen and the second screen. What can be done however is to set a wallpaper, and have it spanned over two screens. We can automatically create a spanning image of two wallpapers of your choice and (also automatically) switch the wallpaper and the picture options, depending on whether the second screen is connected or not.
To make it look nice, it is necessary that at least the vertical screen resolution of both screens is identical, which is the case in your situation.

enter image description here

In practice

Preparation

In this solution, The preparing work you have to do is:

  • First, install imagemagick to automaically create the spanning image:

    sudo apt-get install imagemagick
    
  • Prepare two separate background images of your choice for both the screens:

    • The dimensions should exactly match the screen's dimensions (16:9 in your case)
    • The vertical resolution of both images should be exactly the same.

    call them screen_1.jpeg and screen_2.jpeg (exactly those names). A script will create the spanning image.

  • Create a folder in your home directory and copy both images into the folder.

  • Copy the script below into an empty file and save it as auto_wall.py, together with the two images you prepared.

  • In the head section of the script, there is a line:

    screen_check = "HDMI-0 connected"
    

    if necessary, replace HDMI-0 by <your_second_screenname> (run the command xrandr if necessary to find out)

Run the script (and keep it running in the background) by the command:

python3 /path/to/auto_wall.py

Now if you connect your second screen, the wallpaper on your second screen should switch within a few seconds to screen_2.jpeg you prepared.

  • If all works well, add it to your startup applications.

The script

#!/usr/bin/env python3

import subprocess
import os
import time

curr_dir = os.path.dirname(os.path.abspath(__file__))
screen_check = "HDMI-0 connected"

single_picture = "'file://"+curr_dir+"/screen_1.jpeg'"
double_picture = "'file://"+curr_dir+"/span_image.jpeg'"

def execute_set(command):
    subprocess.call(["/bin/bash", "-c", command])

def execute_get(command):
    return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8").strip()

def switch_tosingle():
    execute_set("gsettings set org.gnome.desktop.background picture-uri "+single_picture)
    execute_set("gsettings set org.gnome.desktop.background picture-options zoom")

def switch_todouble():
    if not os.path.exists(double_picture):
        create_spanimage()
    execute_set("gsettings set org.gnome.desktop.background picture-uri "+double_picture)
    execute_set("gsettings set org.gnome.desktop.background picture-options spanned")

def create_spanimage():
    image_1 = curr_dir+"/"+"screen_1.jpeg"
    image_2 = curr_dir+"/"+"screen_2.jpeg"
    span_image = curr_dir+"/"+"span_image.jpeg"
    execute_set("convert "+image_1+" "+image_2+" "+"+append "+span_image)

def check_ifconnected():
    command = "xrandr"
    check = execute_get(command)
    if screen_check in check:
        return True

def check_wallpaper():
    check = execute_get("gsettings get org.gnome.desktop.background picture-uri")
    if check == single_picture:
        return "single"
    elif check == double_picture:
        return "double"

def arrange():
    test = (check_ifconnected(), check_wallpaper())
    if test == (True, "double") or test == (False, "single"):
        pass
    elif test[0] == True:
        switch_todouble()
    else:
        switch_tosingle()

while True:
    arrange()
    time.sleep(5)

Replacing images

In case you want to change wallpaper(s), just replace one or both of the images you copied to the folder (but mind the name) and remove the span_image.jpeg, created by the script.

I tested it on Ubuntu 14.04 and 14.10, and it worked perfectly. The fact that you use Gnome should not make a difference.

Switching wallpaper settings manually with a key combination

If, for some reason, you would prefer to switch to the spanned wallpaper manually after connecting / disconnecting the external monitor, you can replace the last three lines:

while True:
    arrange()
    time.sleep(5)

by a single line:

arrange()

and add a keyboard shortcut to do the switch: "System Settings" > "Keyboard" > "Shortcuts" > "Custom Shortcuts"

Add the command:

python3 /path/to/auto_wall.py

to a key combination of your choice.